From 119eff01e2ddf0552c1364d671b454091a6c07db Mon Sep 17 00:00:00 2001 From: Mordecai Velasco Date: Tue, 5 Jul 2022 21:15:02 +0800 Subject: [PATCH 1/3] Update Plugins-Guide.md added a reminder when using decorateReply and decorateRequest --- docs/Guides/Plugins-Guide.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Guides/Plugins-Guide.md b/docs/Guides/Plugins-Guide.md index 701b0323e6..7ef0ca4d2c 100644 --- a/docs/Guides/Plugins-Guide.md +++ b/docs/Guides/Plugins-Guide.md @@ -196,6 +196,7 @@ fastify.get('/html', (request, reply) => { reply.html({ hello: 'world' }) }) ``` +Reminder that the `this` keyword is not available on *arrow functions*, when passing functions in *`decorateReply`* and *`decorateRequest`* as a utility, always use a function that is defined using the `function` keyword instead of an *arrow function expression*. In the same way you can do this for the `request` object: ```js From 568b106de83a9bfcaa0cbf006376c895beb019ba Mon Sep 17 00:00:00 2001 From: Mordecai Velasco Date: Tue, 5 Jul 2022 21:45:42 +0800 Subject: [PATCH 2/3] Update Plugins-Guide.md --- docs/Guides/Plugins-Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Guides/Plugins-Guide.md b/docs/Guides/Plugins-Guide.md index 7ef0ca4d2c..e7cb3abb21 100644 --- a/docs/Guides/Plugins-Guide.md +++ b/docs/Guides/Plugins-Guide.md @@ -196,7 +196,7 @@ fastify.get('/html', (request, reply) => { reply.html({ hello: 'world' }) }) ``` -Reminder that the `this` keyword is not available on *arrow functions*, when passing functions in *`decorateReply`* and *`decorateRequest`* as a utility, always use a function that is defined using the `function` keyword instead of an *arrow function expression*. +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 From ebffeea0e3a8288411f413b4e9fccff8bc43e67e Mon Sep 17 00:00:00 2001 From: Mordecai Velasco Date: Tue, 5 Jul 2022 22:02:41 +0800 Subject: [PATCH 3/3] Update Plugins-Guide.md --- docs/Guides/Plugins-Guide.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/Guides/Plugins-Guide.md b/docs/Guides/Plugins-Guide.md index e7cb3abb21..6f1d543525 100644 --- a/docs/Guides/Plugins-Guide.md +++ b/docs/Guides/Plugins-Guide.md @@ -196,7 +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*. +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