AsynchronousLesson 11Free preview
Node Promises
This lesson is part of Node.js · All levels
Summary
A promise is an object that represents a value that is not yet available in the future: pending, fulfilled, or rejected. With Promise, the asynchronous chain of operations can be written more neatly using then, catch, and finally. Methods like all and race even allow for running many promises in parallel.
Key points
- Promises have three status: pending, fulfilled, and rejected
- Then handle the successes, catch handle the errors, finally run in both cases.
- Promise.all waiting for all success; allSettled waiting for all finished with its status
- Promise to avoid callback hell thanks to a flatter chain then
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.