Which fix removes the inefficiency?
async function loadAll(ids) {
const out = [];
for (const id of ids) {
out.push(await fetchOne(id));
}
return out;
}
- Run them together with
Promise.all(map) - Run them together with
Promise.any(map) - Remove the
awaitfrom inside the loop - Change the
for...ofinto aforEach
Awaiting inside the loop serialises the requests; Promise.all runs them in parallel.
Play Problem Solving ▸