DEV Community

Discussion on: What's wrong with Promise.allSettled() and Promise.any()❓

Collapse
 
vitalets profile image
Vitaliy Potapov • Edited

I totally agree - this is useful scenario.
My point is that it can be easily achieved with current api without introducing new methods:

const [r1, r2] = await Promise.all([op1(), op2()].map(p => p.catch(e => e)));

// decode state of operations by simply checking "instanceof Error".
Collapse
 
itscodingthing profile image
Bhanu Pratap Singh

I think it is more about the complexity or how much code you write to achieve same functionality without worrying about the other things.