gpt4 book ai didi

javascript - (bluebird .tap) 无法返回数据,做错了

转载 作者:行者123 更新时间:2023-12-01 02:57:07 25 4
gpt4 key购买 nike

我愿意:

 return new bluebird((resolve) => {

bluebird.resolve()
.tap(saveExcelFiles)
.tap(...)
.tap(() => {
return getZip().then((rows) => {
resolve(rows) // this outer bluebird helps me
return rows;
});
})
;

});

如何返回所有数据(每次点击)或仅在一个 bluebird 包装中返回最后一次点击。

附注我需要排序(一点一点,一点一点)

最佳答案

.tap 明确表示“忽略返回值”,如果您需要返回值 - 使用标准 .then:

.then(() => {
return getZip().then((rows) => {
// Nothing outer.
return rows;
});
});

或者更紧凑:

.then(getZip); // that's it!

此外,您应该返回 promise 链而不是 explicit construction :

return saveExcelFiles().tap(...).then(getZip);

对于整个函数来说应该足够了。

关于javascript - (bluebird .tap) 无法返回数据,做错了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46651405/

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