-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: consume req.body in the form of key-value pairs #233
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Hi. I found that most code snippets in readme do not contain trailing semicolon. Should I remove semicolon from my pull request, or keep it as is? |
thanks, that'd be best! |
After testing in my machine, I found that Maybe we should remove the 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 fooValue = 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+)
})
|
sure thing |
Can you add a unit test for this? So it's sure we won't regress. |
Is the following line enough? Should I write another test for that?
|
actually it is! Landed |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
The pull request add documentation on how to consume
req.body
in key-value pairs.This may help new comers from Express.js