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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -