Given those two pieces of code :
async function waitAll() {
await call1();
await call2();
await call3();
}
And
function callPromises() {
Promise.all([promise1, promise2, promise3]).then(/* .... */)
}
What is the most optimized way to call all my async methods ?
My opinion is that Promise.all
in this situation is faster but I cannot find any answer treating about it.
Of course I am open to any solution that would be better than the two I provided.
Thanks for reading
CodePudding user response:
If the calls are not dependent on each other:
async function callPromises() {
await Promise.all([call1(), call2(), call3()]);
}