Learn JavaScript

Lesson 4 of 9 · Async 2: Promises, async/await and fetch

Module 13 · Async 2: Promises, async/await and fetch

When to Use Which: await or then, all or allSettled, a Pool, or a Callback

Free with an accountReading

By now you know every tool. The hard part in real code is choosing. Zara reviews a pull request from a new teammate. The code works. Yet it awaits ten independent requests in a row. It uses Promise.all where one failure should not kill the page. And it wraps a click handler in a promise that stops listening after the first click.

Checking what this lesson needs for you…

What is inside When to Use Which: await or then, all or allSettled, a Pool, or a Callback

  1. await or then
  2. all, allSettled, race or any
  3. In a row, together, or a pool
  4. When a callback is still right
  5. Choosing by four questions
  6. The comparison table