Full-Stack: Module 2

← Dashboard
Module 2: The Coffee Shop Menu

Working with Data

Fetch from APIs. Parse JSON. Handle async with Promises and async/await.

// Fetch data (async/await)
async function getMenu() {
  const res = await fetch('https://api.coffee.com/menu');
  const data = await res.json();
  return data;
}

// JSON syntax
{ "name": "Latte", "price": 4 }
Pro Tip

Always wrap fetch in try/catch. Handle loading and error states in the UI.

Async

async/await reads like sync code but doesn't block the main thread.