简体   繁体   中英

Why is req.body empty?

Server:

//Body Parser
var bodyParser = require("body-parser");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false}));

Client:

<form enctype="multipart/form-data" method="post" action="../users/editProfile" class="uploadForm">

For some reason, req.body is always empty when I submit the form. It was working perfectly fine before and to my knowledge the only thing I added where 9 more inputs for a total of 15.

What could have caused this ?

I already checked this: req.body empty on posts

None of the answers seem to solve my problem.

You've loaded body parsers that can support:

  • URL encoding
  • JSON encoding

Your form is configured to use multipart/form-data , which is neither of those.

Use the multer parser for multipart/form-data bodies.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM