---
title: "How to await in a loop in JavaScript"
url: https://daily.dev/posts/how-to-await-in-a-loop-in-javascript-ip0laqwt9
source_url: https://flaviocopes.com/await-loop-javascript/
type: article
source: "Flavio Copes"
published: 2022-07-27T06:04:46.945Z
updated: 2022-07-27T06:04:46.944Z
tags: ["golang"]
reading_time: 1
upvotes: 45
comments: 3
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to await in a loop in JavaScript

**[Flavio Copes](https://daily.dev/sources/flaviocopes)** · 1 min read · 45 upvotes · 3 comments

## Summary

You can do the same with a for..in loop to iterate on an object. You need to place the loop in an async function, then you can use await and the loop stops the iteration until the promise we’re awaiting resolves.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://flaviocopes.com/await-loop-javascript/>

## Community discussion

Top comments from developers on daily.dev.

**@lorezz** · 0 upvotes

> Usefull, ty

**@orish123** · 0 upvotes

> we can also use "for in" or "for of "

**@ghost** · 0 upvotes

> Flavio's posts are so easy to digest!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/how-to-await-in-a-loop-in-javascript-ip0laqwt9)
