【发布时间】:2017-11-30 03:02:28
【问题描述】:
我正在使用 NodeJs 和 http 模块来测试我的 Web 服务(Restful API)。有4个服务。第一个服务提供一个 json 响应,我需要为第二个服务创建有效负载。如何将响应保存在变量中以便我可以在下一个请求中使用它?
function callback(error, response, body) {
if (!error) {
var info = JSON.parse(JSON.stringify(body));
console.log(info);
}
else {
console.log('Error happened: '+ error);
}
}
//sending request
request(options, callback);
【问题讨论】:
-
到目前为止你尝试过什么?有代码示例吗?
标签: json node.js web-services