【问题标题】:async waterfall not executing next callback method when used with a promise与 Promise 一起使用时,异步瀑布不执行下一个回调方法
【发布时间】: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


    【解决方案1】:

    我修改了,问题解决了

    nextCallback(null, itemResult);
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 2011-02-24
      • 2017-08-03
      • 2016-01-13
      • 2017-03-02
      • 2017-04-26
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      相关资源
      最近更新 更多