I currently have this code:
const promise1 = aPromiseCall().then(r => logger(r)).catch(e => logger(e));
const promise2 = anotherPromiseCall().then(r => logger(r)).catch(e => logger(e));
and in an async function I do:
const results = Promise.all([promise1, promise2]);
I do it this way because I want to ensure that if promise1 fails, I still can do promise2. However, I don't know if that's the best way to accomplish this. Should I be doing those then, catch
in each promise or is there a more idiomatic way of doing this?
At the same time I want to guarantee that ALL the promises are resolved/rejected before I continue the execution of my code, and that's why I put them in a Promise.all
.