【发布时间】:2016-07-19 19:03:01
【问题描述】:
你如何从一个 then() 函数中的 Promise 访问内容,在下一个 then() 函数中访问它。
我的问题通过下面的代码大致解释了。
someRandomPromiseFunction().then(function(theArray) {
var newProm = _.map(theArray, function(arrayItem) {
return new Promise(function(resolve, reject) {
resolve(arrayItem);
});
}
Promise.all(newProm).then(function(theArray) {
return theArray; // How do I access this in the next then() function
}).catch(function(err) {
return err;
});
}).then(function(theArray) {
console.log(theArray); // I need to access theArray from the Promise.all HERE
});
【问题讨论】:
标签: javascript promise resolve