Is it possible in a middleware to get the data just sent by my API ?
For exemple I have a nodejs Server with this middleware:
var middleware = function(req, res, next) {
res.on('finish', function() {
console.log(res.statusCode); // display 200
console.log(res.body); // display empty data
});
next();
};
And my API:
app.get('/url', function(req, res) {
res.status(200).json({name:'john'}).end();
});
But in my middleware, I only can get the statusCode '200', but not the object {name:'john'}
.
Anyone can help me ?
Thanks.