I'm just getting around to changing some of my code to ES6 and I ran across some code where the arrow function did not work and I am not sure I understand why. The code is from a plugin for Hapi to decorate the reply
interface.
ES5:
server.decorate('reply', 'test', function(schema, response) {
return this.response(mask(schema, response));
});
ES6:
server.decorate('reply', 'test', (schema, response) => {
return this.response(mask(schema, response));
});
The E66 doesn't work and throws an error:
Uncaught error: this.response is not a function
Why is this?