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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -