To get raw request body using Express with Node.js, we use the req.body
property.
For instance, we write
const bodyParser = require("body-parser");
app.use(bodyParser.raw(options));
app.get(path, (req, res) => {
console.log(req.body);
//...
});
to call app.get
to create a route handler for the path
path.
Then we get the request body with req.body
.
req.body
is a buffer object.
We use the bodyParser.raw
middleware to parse the request body into a buffer.