Full stack development

Stage 1 · Lesson 6 of 8

Promises and async/await

Web foundations: HTML, CSS and JavaScript

Network calls, file reads and database queries take time. So gives you a : a placeholder for a value that will be ready later, or an error. async/await lets you write this code top to bottom. await pauses the function until the promise finishes, and try/catch handles a failure.

Use Promise.all to run independent requests at the same time rather than one after another. Three calls of 300ms each then take about 300ms in total instead of 900ms. You will write this pattern in every route and database call later.

Common trapThe common traps are forgetting await and awaiting inside a loop. Without await you log a pending promise instead of the data. Awaiting in a loop runs calls one by one, even when they do not depend on each other.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    Guided course on the language core if you want structure and quizzes

  • CourseFree
    The Odin Project

    The Odin Project · Beginner

    Free Foundations course: HTML, CSS and JavaScript built in your own editor

Practise

  • Real designs to rebuild, so layout and interactivity get proper practice

Keep handy

  • The reference for HTML, CSS, JavaScript and browser APIs

  • Quick syntax lookups for HTML, CSS and JavaScript while you build

Also worth your time

Mark this stage as not done?