承诺连锁打破

问题描述 投票:1回答:1

我有一个破坏的承诺链(蓝鸟),我无法弄清楚原因。

 Promise.resolve()
   .then(function() {
     [..]
   })
   .then(function() {
     [..]
   })
   .then(function() {
     [..]
   })
   .spread(function(instance) {
     [..]
   })

这与TypeError: undefined is not a function上的.spread失败了。最后console.log上的.then()显示它返回{}。交换spreadthen使代码运行。我究竟做错了什么?什么会使传播未定义?


更新:将最后一个spread更改为下面的代码使其工作。

   .then(function(arr) {
     var instance = arr[0];
     [..]
   })
javascript promise bluebird
1个回答
1
投票

我是个白痴:)错过了包括该文件中的蓝鸟,所以它使用的native implementation of promises没有spread

© www.soinside.com 2019 - 2024. All rights reserved.