Modern Asynchronous JavaScript: error in "Executing Multiple Promises" (page 22)

@Faraz

The text after the code promise.allSettled/tracking_promises_ex02.js says, “In other words, this code will load the post sequentially rather than making multiple requests at the same time.” But that’s wrong. Since the nameless function inside the poistIds.forEach is async, as soon as some asynchronous code is called the nameless returns (an unsettled Promise) and the next iteration starts. In fact, the four calls execute just as concurrently as they do in the next tracking_promises_ex03.js example. To make the loop iterations run sequentially, you have to write a for loop such as,

for (const id of postIds) {
  const post = await getPost(id);
  // process the post
}