api/config.js export const config = { api: { bodyParser: true, // Enable default body parser to handle manually }, }; With bodyParser: true, Next.js automatically parses the incoming request body. So you can retrieve data automatically as a simple object const { name, age } = req.body; Next.js looks at conteent-type of request and does magic transformation magic itself. The bodyParser configuration option for Next.js API routes has been available since at least version 9.5.4 of Next.js.
@ОленаНехрищинюк
3 ай бұрын
Not enough likes for such a good video
@oopss794
Жыл бұрын
hi , how to set limits (e.i maximum file size) in my next js api ?
@JavascriptForEverything
Жыл бұрын
as you can see I shows the Blob in my Console in Server Side right ?, you can set any number conditionally, for example: if(avatar.size >= 10240) throw new Error('Your File size is more than 10 MB ) ... fs.writeFile(...)
@oopss794
Жыл бұрын
I'm planning to use request.formData() , the new way for streaming incoming files
Пікірлер: 7