Ich stieß auf ein Problem in Bluebird/Promises. Für die Promise1 funktioniert alles gut, wenn Call Fullfill oder Reject. Wenn wir jedoch Promise2 in einem finally-Block zurückgeben, funktioniert es nur für die Zurückweisung, und für das Fullfil werden wir im Callback von undefiniert.Bluebird Versprechen - dann nach endlich
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);
});
Ausgang:
OK1
undefined