Node.js Req.body Empty
I am having a hell of a time with this one. I don't know why my node.js response is empty. It comes back {} if I send it through the javascript here, or if I use the Advanced RES
Solution 1:
You are sending json in the request, but you only have middleware setup to handle url encoded requests. Add this to your middleware and json requests should populate in the req.body.
app.use(bodyParser.json());
More info can be found at in the body parser documentation. Specifically you'll notice that the middleware you are usingurlencoded
states that it only parses urlencoded bodies (this is where Content-Type is used).
Post a Comment for "Node.js Req.body Empty"