Req.body Undefined Multipart
I have a problem with my POST request on multipart (form-data). All ideas in other topics don't work. I use express, multer and postman I totally delete body-parser Uploading file
Solution 1:
Since you're using multer to parse the request body, you're going to need to invoke multer prior to accessing req.body
. The way you are currently using multer, it will extract the information from the request to process the file but will not be part of the middleware stack so you don't get the benefit of the body parsing prior to your route being called.
Add the multer middleware into the route signature and so it the request body will be parsed by multer prior to the route callback being invoked. For example like this
router.post('/', upload.single('avatar'), (req, res, next) => {
console.log(req.body.firstName)
})
Post a Comment for "Req.body Undefined Multipart"