I have a small api I have built using Node.js and express. I am trying to create a logger and I need log the request body AND response body.
app.use((req, re
You need body-parser that will create body object for you in your request.
To do that
npm install body-parser
var bodyParser = require('body-parser')//add this
app.use(bodyParser())//add this before any route or before using req.body
app.use((req, res) => {
console.log(req.body); // this is what you want
res.on("finish", () => {
console.log(res);
});
});