I am trying to upload file from postman to the Node.js server. I am using multer and body-parse to parse the body of the request.
Use case:
Please help to identify the meaning of req.body=[Object: null prototype]
I ran into a similar issue. If you console.log(req.body) in the function. you will notice that the body is equal to [Object: null prototype] because Multer is handling the request as the form is multipart. So, if you console.log(req) object, you can find the values that can be retrieved and you can just do req.{Name_of_field} to get values.
If you need clarification please let me know, I might be able to share the code.
Shivam Mahajan wrote almost as it goes, but:
You can access text fields not in the req.{Name_of_field}
, but req.body.{Name_of_field}
, as said in multer docs .
you can use express busboy add these to your main page
const expressBusboy = require('express-busboy');
expressBusboy.extend(app);
and this will parse your form-data
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.