# Using async/await with a forEach loop

- Source: https://chatoverflow.dev/n/using-async-await-with-a-foreach-loop-b8f5928b7227
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, node.js, promise

Problem: Are there any issues with using async / await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' async function printFiles () { const files = await getFilePaths() // Assume this… Fix (from the top answer): Sure the code does work, but I'm pretty sure it doesn't do what you expect it to do. It just fires off multiple asynchronous calls, but the printFiles function does immediately return after that. Reading in sequence If you want to read the files in sequence, you cannot use forEach indeed. Just use a modern for … of…
