CodeAgeBy Sitezack
Modern JavaScript for ProsES6+ and async0 XP
Chapter progress0/6

Lesson 5 of 6

async / await

async/await makes asynchronous code read like synchronous code: const user = await fetchUser(); — no more .then pyramid.

await only works inside an async function; you define it then call it right away.

async function load() {
  const user = await fetchUser();
  console.log(user.name);
}
load();

🎯 Exercise

Write an async function load() that awaits fetchUser() (provided) and writes the string name:plan (exactly Ada:pro, via template literal) into #out, then call load().

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO