admin 管理员组文章数量: 1086019
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.
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.
Share Improve this question edited Aug 25, 2017 at 16:44 abagshaw 6,6226 gold badges43 silver badges80 bronze badges asked Aug 25, 2017 at 16:29 TheProgrammerTheProgrammer 1,5094 gold badges30 silver badges54 bronze badges1 Answer
Reset to default 10You'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.
本文标签: javascriptWhy is reqbody emptyStack Overflow
版权声明:本文标题:javascript - Why is req.body empty? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744058798a2526336.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论