async瀑布在与promise一起使用时不执行下一个回调方法

时间:2016-04-25 18:33:09

标签: javascript angularjs node.js asynchronous

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)只打印一次,这意味着没有正确调用回调?

1 个答案:

答案 0 :(得分:0)

我修改了,问题得到了修复

git commit -m ".gitignore is now working"