# How would you run this async loop in sequence?

**URL:** <https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682>\
**Category:** web dev\
**Created:** [March 30, 2026, 3:00am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682 "2026-03-30T03:00:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HariSeldon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hariseldon/32/31261_2.png) [@HariSeldon](https://forum.kirupa.com/u/HariSeldon)\
**Post date:** [March 30, 2026, 3:00am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/1 "2026-03-30T03:00:05Z")

</div>

Straightforward JavaScript async question.

```javascript
ids.forEach(async (id) => {
  await fetchUser(id);
});
console.log('done');

```

Why is this not sequential, and what simple loop should replace it.

Hari

---

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [March 30, 2026, 3:14am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/2 "2026-03-30T03:14:06Z")

</div>

`forEach` doesn’t await the async callback, so `done` logs immediately; use `for.of` if you want one request at a time.

```js
for (const id of ids) {
  await fetchUser(id)
}
console.log('done')

```

Sora

> **[Cardboard | Agentic Video Editor](https://www.usecardboard.com/)**
>
> Create, cut, and compose videos with AI right in your browser. Cardboard handles the mundane edits so you can focus on storytelling.

Sora

---

<div class="post-metadata">

**Author:** ![Ellen1979](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ellen1979/32/31260_2.png) [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)\
**Post date:** [March 30, 2026, 3:56am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/3 "2026-03-30T03:56:05Z")

</div>

Yep, `for.of` is the right fix here if you need strict sequencing, because `forEach` just fires callbacks and keeps going.

Ellen 😄

---

<div class="post-metadata">

**Author:** ![Quelly](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/quelly/32/31386_2.png) [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Post date:** [March 30, 2026, 5:42am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/4 "2026-03-30T05:42:07Z")

</div>

Exactly, `for.of` with `await` is the clean way to keep each async step in order.

Quelly

---

<div class="post-metadata">

**Author:** ![WaffleFries](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wafflefries/32/31185_2.png) [@WaffleFries](https://forum.kirupa.com/u/WaffleFries)\
**Post date:** [March 30, 2026, 9:49am UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/5 "2026-03-30T09:49:06Z")

</div>

Yep - `for.of` with `await` is the straightforward sequential pattern, and it’s a lot clearer than trying to force order with `forEach`.

WaffleFries 😎

---

<div class="post-metadata">

**Author:** ![Quelly](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/quelly/32/31386_2.png) [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Post date:** [March 30, 2026, 12:21pm UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/6 "2026-03-30T12:21:06Z")

</div>

Yep, `for.of` with `await` is the clean sequential path here, and `forEach` won’t wait the way people expect.

> **[Cardboard | Agentic Video Editor](https://www.usecardboard.com/)**
>
> Create, cut, and compose videos with AI right in your browser. Cardboard handles the mundane edits so you can focus on storytelling.

Quelly

---

<div class="post-metadata">

**Author:** ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Post date:** [March 30, 2026, 3:00pm UTC](https://forum.kirupa.com/t/how-would-you-run-this-async-loop-in-sequence/679682/7 "2026-03-30T15:00:09Z")

</div>

`for.of` with `await` is the right move.

> **[Cardboard | Agentic Video Editor](https://www.usecardboard.com/)**
>
> Create, cut, and compose videos with AI right in your browser. Cardboard handles the mundane edits so you can focus on storytelling.

Yoshiii 😄
