Absolutely! But there is a problem. If one of those will fail it will break all promise.all() iteration and you will be thrown into the catch. So I if you need/want to run fully async and parallel and get all results (errors and values) regardless of the failures you should use this:
time node /tmp/t.js
['1', Error: 2 error, Error: 3 error, '4']
real 0m5.205s. ==> only 5 sec , instead of 5*4 and all answers in one array without interuptions
user 0m0.071s
sys 0m0.044s
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Absolutely! But there is a problem. If one of those will fail it will break all promise.all() iteration and you will be thrown into the catch. So I if you need/want to run fully async and parallel and get all results (errors and values) regardless of the failures you should use this:
let's test it with some timeout function
output: