承诺连锁打破

时间:2015-06-02 07:22:04

标签: javascript promise bluebird

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

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

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

更新:将上一个spread更改为以下代码可以使其正常工作。

   .then(function(arr) {
     var instance = arr[0];
     [..]
   })

1 个答案:

答案 0 :(得分:1)

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

相关问题