Home > Enterprise >  Formdata is passing null value in req.body nodejs
Formdata is passing null value in req.body nodejs

Time:10-22

I am passing a uploaded file through formdata from client to server, and the request by the server received has empty body. Here is the code, can someone please help?

Client side code -

enter image description here

Server side code -

enter image description here

enter image description here

OUTPUT -

browser console -

browser console

nodejs console -

enter image description here

CodePudding user response:

You need to use a middleware like multer to parse form-data

CodePudding user response:

Your content-type will be

multipart/form-data

Not an application/json

Try to make something like this: https://programmingwithmosh.com/javascript/react-file-upload-proper-server-side-nodejs-easy/

  • Related