Node.js · Junior · Question 38 of 75
How do you run two independent async requests in parallel and wait for both?
- ✓Correct answer:
await Promise.all([getUser(), getOrders()]) - 2
Promise.wait(getUser, getOrders) - 3
await getUser(); await getOrders();
Explanation
Two awaits in a row run one after another, so the total time is the sum. Promise.all starts both at once and rejects as soon as one fails; Promise.allSettled waits for all results.