Consider this snippet.
ids.forEach(async (id) => {
await fetchUser(id);
});
console.log('done');
Why is this not sequential, and what simple loop should replace it.
Sarah
Consider this snippet.
ids.forEach(async (id) => {
await fetchUser(id);
});
console.log('done');
Why is this not sequential, and what simple loop should replace it.
Sarah
forEach doesn’t await the async callback, so it fires all the fetches and done logs immediately.
WaffleFries
:: Copyright KIRUPA 2024 //--