Day 4: The Fetch API (GET) & Network Tab
Daily Objective
Section titled “Daily Objective”Consume public REST APIs using fetch, inspect status codes (response.ok), and inspect requests in DevTools Network tab.
1. Fetching Data
Section titled “1. Fetching Data”async function getPokemon(name) { const res = await fetch(`https://pokeapi.co/api/v2/pokemon/${name}`); if (!res.ok) throw new Error(`Pokemon not found (Status: ${res.status})`); const data = await res.json(); return data;}Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Open DevTools Network tab, filter by Fetch/XHR, and inspect status codes, headers, and response payloads.