From 3d3c8fb0cbde9ef9e44b1d28b763fbf06af8fd6c Mon Sep 17 00:00:00 2001 From: Mordecai Velasco Date: Wed, 6 Jul 2022 03:30:26 +0800 Subject: [PATCH] docs(Plugins-Guide.md) : add this reminder (#4117) * Update Plugins-Guide.md added a reminder when using decorateReply and decorateRequest * Update Plugins-Guide.md * Update Plugins-Guide.md --- docs/Guides/Plugins-Guide.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/Guides/Plugins-Guide.md b/docs/Guides/Plugins-Guide.md index 701b0323e6..6f1d543525 100644 --- a/docs/Guides/Plugins-Guide.md +++ b/docs/Guides/Plugins-Guide.md @@ -196,6 +196,11 @@ fastify.get('/html', (request, reply) => { reply.html({ hello: 'world' }) }) ``` +Reminder that the `this` keyword is not available on *arrow functions*, +so when passing functions in *`decorateReply`* and *`decorateRequest`* as +a utility that also needs access to the `request` and `reply` instance, +a function that is defined using the `function` keyword is needed instead +of an *arrow function expression*. In the same way you can do this for the `request` object: ```js