Using async/await with a forEach loop

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 loop instead, in which await will … Read more