Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

Async/Await

Async/await lets you write code that waits for things to finish (like loading data).

async function getData() {
  const response = await fetch('https://api.example.com/data');
  const data = await response.json();
  console.log(data);
}

Key rules:

  • Add async before the function
  • Use await to wait for operations that take time
  • await can only be used inside async functions