【发布时间】:2015-09-15 16:37:12
【问题描述】:
我在 Bluebird/Promises 中遇到了一些问题。 对于 Promise1,如果调用 fullfill 或拒绝,一切正常。但是,当我们在 finally 块中返回 Promise2 时,它仅适用于拒绝,而对于 fullfil,我们在 then 的回调中得到 undefined。
function getPromise1() {
return new Promise(function(fulfill, reject) {
fulfill("OK1");
});
}
function getPromise2() {
return new Promise(function(fulfill, reject) {
fulfill("OK2");
});
}
getPromise1()
.then(function(c){
console.log(c);
})
.catch(function(e) {
console.log(e);
})
.finally(function() {
return getPromise2();
})
.then(function(c){
console.log(c);
})
.catch(function(e) {
console.log(e);
});
输出:
OK1
未定义
【问题讨论】:
标签: javascript node.js promise bluebird