【发布时间】:2013-12-26 02:41:17
【问题描述】:
我想对数组中的每个元素进行 http 调用,并将所有响应合并到一个数组中,如下所示:
result = [] ; i = 0
for item in array
options = get_options(item)
request options, (err, res, body)->
result[i++] = body
// when all calls are done, console.log the 'result' array
我正在查看异步模块,但我不确定如何使用它。
【问题讨论】:
-
你可能想使用异步库。
-
您如何看待韩国的问题?
-
@askkirati,正如我在问题中提到的,我知道异步模块,但我不知道如何并行发出请求并在数组中获取结果。如果您知道该怎么做,请将其添加为答案。
标签: javascript node.js http asynchronous coffeescript