CodeAgeBy Sitezack
JavaScript moderne pour ProsES6+ et asynchrone0 XP
Progression du chapitre0/6

Leçon 5 sur 6

async / await

async/await rend l'asynchrone lisible comme du code synchrone : const user = await fetchUser(); — plus de pyramide de .then.

await ne fonctionne que dans une fonction async ; on la définit puis on l'appelle immédiatement.

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

🎯 Exercice

Écrivez une fonction async load() qui attend fetchUser() (fournie) et écrit la chaîne name:plan (exactement Ada:pro, via template literal) dans #out, puis appelez load().

Leçon PRO

Ce chapitre avancé fait partie de CodeAge PRO. Débloque-le pour continuer ton aventure.

Découvrir PRO