Javascript Promises - get Array of non rejected -


i need function can take array<promise<object>> , return promise<array<object>>.

it similar promise.all(), instead of failing on reject ignores them, , moves on.

you can use promise.all transform array<promise<x>> promise<array<x>>.

to ignore rejections, handle them , return null value instead:

promise.all(promises.map(p => p.catch(err => undefined))) 

if interested in filtering them out, use this approach post-processes array.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -