有没有办法查看完整的原始HTTP请求和响应以使调试更容易? 这是节点模块(https://www.npmjs.com/package/node-rest-client)和示例。
var Client = require('node-rest-client').Client;
client = new Client();
args = {
path:{"p1":"1234", "p2":"abcd"}
headers:{"Authorization":"01234567890"}
}
client.get("http://example.com/${p1}/${p2}", args, function(data, response){
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
}).on('error',function(err){
console.log('something went wrong on the request', err.request.options);
});
答案 0 :(得分:0)
根据source code,Client.get()
函数返回常规字符'请求对象由节点的http
或https
模块创建(最终,在引擎盖下)。因此,请尝试检查client.get()
的返回值并查看其中的内容。