【发布时间】:2016-01-09 11:35:04
【问题描述】:
使用节点 4.x。当您有 Promise.all(promises).then() 时,解析数据并将其传递给下一个 .then() 的正确方法是什么?
我想做这样的事情:
Promise.all(promises).then(function(data){
// Do something with the data here
}).then(function(data){
// Do more stuff here
});
但我不确定如何将数据发送到第二个.then()。我不能在第一个.then() 中使用resolve(...)。我发现我可以做到这一点:
return Promise.all(promises).then(function(data){
// Do something with the data here
return data;
}).then(function(data){
// Do more stuff here
});
但这似乎不是正确的方法……正确的方法是什么?
【问题讨论】:
标签: javascript node.js promise