【问题标题】:how to get response body in restify after event?如何在事件发生后得到响应体?
【发布时间】:2015-02-06 02:25:52
【问题描述】:

我尝试在下面的函数中调试/记录响应参数,但它不包含实际的正文。

函数(请求、响应、路由、错误){}

以上函数取自 restify 文档。下方链接: http://mcavage.me/node-restify/#Server-API

这是我的代码:

server.on('after', function(req, resp, route, error) {
    console.log(resp);
});

提前致谢!

【问题讨论】:

  • 你能展示剩下的代码吗?这个函数在哪里调用?如何?请注意:错误参数通常是第一个。
  • 我已经编辑了问题。

标签: node.js events httpresponse restify


【解决方案1】:

阅读https://github.com/mcavage/node-restify/blob/master/lib/response.js

在第201行,可以看到发送的实体在resp._data下

【讨论】:

    猜你喜欢
    • 2017-09-15
    • 2022-11-24
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多