Here is the simplified version of the problem;
there are some promises, few .then()
chains, and a .catch()
block for error handling;
each promise might resolve or reject hence I use Promise.allSetted
to know which promise had been failed based on their order in array and their status; It works fine when all promises resolve but when a promise is rejected, it's status will be shown as "fulfilled" in Promise.allSetteld
; If I remove the .catch()
block, It will work as expected but we need to keep the .catch()
block for logging to the store; So why isn't it just behave as expected? is there any way to make it show "rejected" status with .catch()
block?
let a = Promise.resolve("a: Promise.resolved").then(response => response).catch(err=>console.log(err));
let b = Promise.reject("b: Promise.rejected").then(response => response); // no error handling
let e = Promise.reject("e: Promise.rejected").then(response => response).catch(err=>console.log(err));
Promise.allSettled([a,b,e]).then( values => console.log(values) );