Reputation: 995
I successfully retrieved data in node when it was x-www-form-urlencoded
or raw
.
app.use(express.json());
app.use(express.urlencoded());
app.post("/api/posttest", (req, res) => {
console.log(req.body);
res.send("POST data received");
});
But when I use form-data
, the req.body
is empty and I didn't find my data anywhere else in req
. Can this be retrieved with express without additional modules?
Upvotes: 1
Views: 222
Reputation: 11
I believe you need the express.js middleware 'body-parser' in order to retrieve/see req.body.
Body parser used to be part of express.js but has since been removed.
Upvotes: 1