JS ASYNCChapter 6 · JS Async and Errors
Promises
A Promise stands for a value that is not ready yet. It starts pending, then either fulfills with a value or rejects with an error. .then(fn) runs when it fulfills, .catch(fn) when it rejects, and .finally(fn) either way. Promise.all waits for several promises and fails as soon as any one rejects; Promise.allSettled waits for every one of them no matter what.
Worked example
How it reads
- Each
.thenreceives what the previous step returned Promise.allkeeps the results in the order you passed the promises- The rejection is caught first: it needs no timer, so it settles right away
Common mistakes
- A promise chain with no
.catchhides errors. Every chain should end with a catch, or be awaited inside try...catch.

Cloud tip: Return the next promise from inside
.then to keep a chain flat instead of nesting callbacks.

