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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -