Node.js · 14-day planAll days
Day 5 of 14 30 minCallbacksPromisesasync/await
Node does slow work like file and network I/O without waiting. Learn error-first callbacks and why they get messy, convert them to promises with util.promisify, write clear code with async/await, run work in parallel with Promise.all and friends, and handle errors and timeouts.
By the end of today you can
- Write and read error-first callbacks
- Turn callback APIs into promises with util.promisify
- Use async/await with try/catch
- Run tasks in sequence or in parallel with Promise.all and Promise.allSettled
- Add timeouts and cancellation with AbortController
What's inside
- 5 sections
- 3 diagrams and mind maps
- 7 code examples you can run
- 5-question quiz
- 1Error-first callbacks
- 2Promises and util.promisify
- 3async/await
- 4Sequence or parallel?
- 5Timeouts and cancellation
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free