Request

The first parameter of the handler function is Request.Request is a core Fastify object containing the following fields:

  • query - the parsed querystring
  • body - the body
  • params - the params matching the URL
  • headers - the headers
  • raw - the incoming HTTP request from Node core (you can use the alias req)
  • id - the request id
  • log - the logger instance of the incoming request
  1. fastify.post('/:params', options, function (request, reply) {
  2. console.log(request.body)
  3. console.log(request.query)
  4. console.log(request.params)
  5. console.log(request.headers)
  6. console.log(request.raw)
  7. console.log(request.id)
  8. request.log.info('some info')
  9. })

原文: https://www.fastify.io/docs/v2.0.x/Request