【发布时间】:2011-11-19 22:07:38
【问题描述】:
对不起,如果这个问题很简单,但我使用 node.js 才几天。
基本上我会收到一个带有一些条目的 json。我循环访问这些条目并为每个条目启动一个 http 请求。像这样的:
for (var i in entries) {
// Lots of stuff
http.get(options, function(res) {
// Parse reponse and detect if it was successfully
});
}
如何检测所有请求何时完成?我需要这个才能调用 response.end()。
我还需要告知每个条目是否成功。我应该使用全局变量来保存每个条目的结果吗?
【问题讨论】:
标签: node.js