【发布时间】:2016-08-19 07:24:17
【问题描述】:
async.waterfall(eventIDs.map(function (eventId) {
console.log(eventId);
return function (lastItemResult, nextCallback) {
if (!nextCallback) {
nextCallback = lastItemResult;
lastItemResult = null;
}
// same execution for each item in the array
var eventPromise = loadEventsData.loadFormData(eventId, apiList);
eventPromise.then(function (response) {
console.log(response);
var itemResult = response;
// results carried along from each to the next
nextCallback(itemResult, nextCallback);
});
}}), function (err, result) {
// final callback
});
console.log(eventId) 的输出是正确的,它被打印的次数与数组中的项目一样多。但是console.log(response) 只打印一次,这意味着没有正确调用回调?
【问题讨论】:
标签: javascript angularjs node.js asynchronous