【发布时间】:2017-06-27 06:43:29
【问题描述】:
在 server.js 文件中,我添加了来自 ref 的以下代码。它按预期给了我 req.body 。但是否也可以记录 response.body ?如何。 我试图打印 res.body 它给了我很长的响应对象,但不是实际的响应正文。
app.middleware('initial', function logResponse(req, res, next) {
// install a listener for when the response is finished
res.on('finish', function() {
// the request was handled, print the log entry
console.log(res.body, req.originalUrl, res.statusCode);
});
// resume the routing pipeline,
// let other middleware to actually handle the request
next();
});
【问题讨论】:
-
您能解释一下“响应的日志对象”是什么意思吗?
-
这是错字:长
-
好的,据我了解,您已经拥有了网络服务器,并且想要接收服务器发送的每条响应消息?
-
没错! !
标签: node.js http express loopbackjs