Session Plan
This guide is for mentors. It outlines how to run the session, what to emphasize, and why we introduce certain terminology.
Session Goals
By the end of this session, trainees should:
Understand why Promises exist (solving callback hell)
Consume Promises with
.then()and.catch()Create Promises with
new Promise()Use
async/awaitfor cleaner async codeHandle errors with
try/catchUse
Promise.all()for parallel operationsFetch data from the Tea Shop API
Glossary Goals
Promise
Core concept for modern async JavaScript. They'll use this everywhere.
resolve / reject
Understanding Promise outcomes is essential for proper error handling.
then / catch
The foundational API for working with Promises.
async / await
Modern syntax they'll use daily. Built on Promises.
Promise.all
Essential for performance - parallel operations.
Session Outline
1. Introduction
Recall Week 2: callback hell example
"There has to be a better way" - introduce Promises
Show the transformation: nested callbacks → chained Promises → async/await
Use: Slides (introduction sections)
2. Promise Consumption
Start with consuming, NOT creating Promises
Use
fetch()- a real function that returns a PromiseLive code: fetch teas from the API
Explain
.then()and.catch()Emphasize:
.then()returns a Promise (enables chaining)
Key point: "When you have a Promise, you can call .then() for success and .catch() for failure."
Exercises: Part 1 (exercises 1-4)
3. Chaining Promises
Show chaining: one
.then()after anotherThe return value becomes the next
.then()'s inputOne
.catch()at the end handles all errorsCompare to callback hell: flat vs nested
Key point: "Each .then() returns a new Promise. That's what makes chaining work."
Exercises: Part 2 (exercises 5-6)
Break 1
4. Creating Promises
Now show how to CREATE Promises
new Promise((resolve, reject) => { ... })Convert callback-based code to Promise-based
Live code: promisify
setTimeoutLive code: promisify
fs.readFile
Key point: "resolve = success, reject = failure. You decide when to call them."
Exercises: Part 3 (exercises 7-9)
5. async/await
"Promises are great, but there's even cleaner syntax"
asyncmakes a function return a Promiseawaitpauses until Promise resolvesLive code: rewrite
.then()chains with async/awaitError handling with
try/catch
Key point: "async/await is just Promises with nicer syntax. The code looks synchronous but runs asynchronously."
Exercises: Part 4 (exercises 10-13)
Break 2
6. Promise.all
Problem: sequential requests are slow
Solution: run them in parallel with
Promise.all()Live code: fetch multiple teas at once
Show timing difference
Key point: "Promise.all runs operations in parallel. Much faster when requests don't depend on each other."
Exercises: Part 5 (exercises 14-15)
7. Wrap-up
Recap: Promises → .then/.catch → async/await → Promise.all
Mention Part 6 (Authentication) as optional stretch for fast learners
Preview Week 4: "Next week we organize code with Classes"
Introduce the assignment
Teaching Tips
Managing exercises with mixed skill levels
The exercises are intentionally numerous - trainees progress at different speeds. Here's how to manage this:
Let trainees work on Part 1 - observe how far each gets individually
Solve one exercise in plenum - pick one that weaker trainees struggled with but stronger trainees just finished. This way everyone benefits
Move on to Part 2 - weaker trainees skip remaining Part 1 exercises (they can revisit later)
Repeat for each part
Exercises marked with ⭐ are optional stretch goals. If your fastest trainees finish all exercises while others haven't solved the first one, that part needs an additional challenge - let us know, or create a PR with a creative challenging exercise!
Teach consumption before creation
trainees often get confused when Promise creation and consumption are mixed. Teach them separately:
First: "Here's a Promise (from fetch). How do we USE it?"
Later: "How do we CREATE our own Promises?"
The order matters
Don't explain async/await until they understand .then/.catch. async/await is sugar on top of Promises - if they don't understand Promises, async/await will be magic they can't debug.
Use real API calls
The Tea Shop API makes exercises concrete. trainees see real network delays, real errors, real data. Much more engaging than setTimeout simulations.
Common mistakes to watch for
Forgetting
await(getting Promise objects instead of values)Forgetting to return in
.then()chainsNot handling errors (no
.catch()or try/catch)Using
awaitoutside anasyncfunction
Materials
Slides - Reveal.js presentation
Exercises - In-session exercises
Assignment - Take-home work
Tea Shop API - Live API for exercises
Last updated