Skip to content

Commit

Permalink
docs: consume req.body in the form of key-value pairs (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hk authored May 15, 2021
1 parent d3790a1 commit d615973
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ fastify.register(require('fastify-multipart'), { attachFieldsToBody: true })
fastify.post('/upload/files', async function (req, reply) {
const uploadValue = await req.body.upload.toBuffer() // access files
const fooValue = await req.body.foo.value // other fields
const body = Object.fromEntries(
Object.keys(req.body).map((key) => [key, req.body[key].value])
) // Request body in key-value pairs, like req.body in Express (Node 12+)
})
```

Expand Down

0 comments on commit d615973

Please sign in to comment.