Documentation

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

Sections

Fetch GET Request

Use fetch() to get data from an API.

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

Steps:

  1. await fetch(url) - sends request and waits for response
  2. await response.json() - converts response to usable JavaScript data
  3. Access properties with dot notation: data.temperature