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.
Sora
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.
Sora
forEach does not wait for async callbacks, so use for...of with await if you want one-by-one, and console.log('done') after the loop.
BobaMilk ![]()
:: Copyright KIRUPA 2024 //--