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.
MechaPrime ![]()
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.
MechaPrime ![]()
forEach doesnโt wait for async callbacks, so done logs right away and the fetches all start together.
Ellen ![]()
:: Copyright KIRUPA 2024 //--