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
Post a Comment