gpt4 book ai didi

javascript - Bluebird promise 每次返回结果

转载 作者:行者123 更新时间:2023-11-30 16:19:21 25 4
gpt4 key购买 nike

我正在使用 bluebird 在 nodejs 中链接一些与幻影相关的任务。我的问题是链中的最后一个 then 将参数传递给 each 作为其结果而不是 scrapDomain 函数的结果

我已经搞砸了 2 天了,请帮忙?

promise 链:

Promise
.each(domains, function(domain) {
return ensureDir(domain[0])
})
.each(ssHome)
.each(function(domain){
return scrapDomain(domain).then(function(results){
return results
})
})
.then(function(results){
console.log(results)
})

最佳答案

参见 http://bluebirdjs.com/docs/api/promise.each.html

Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, then the result of the promise is awaited, before continuing with next iteration.

我想你想使用 http://bluebirdjs.com/docs/api/promise.map.html

关于javascript - Bluebird promise 每次返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34975365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com