preHandler vs onRequest
#3772
-
It is not entirely clear when one would use one or another. |
Beta Was this translation helpful? Give feedback.
Answered by
Eomm
Mar 14, 2022
Replies: 1 comment 9 replies
-
The main difference is that the So, do you need to manipulate the body? Use |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
RafaelGSS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main difference is that the
onRequest
has not the body payload parsed, thepreHandler
has ithttps://www.fastify.io/docs/latest/Reference/Lifecycle/#lifecycle
So, do you need to manipulate the body? Use
preHandler
Do you need to know that a request has come into the server? Use
onRequest