Lesson 15 of 18

🌐 Fetch & APIs

🎯 Grades 9–12 ⏱ ~40 minutes 🔴 Advanced

What You'll Learn

  • What APIs are and how JSON works
  • Using fetch() with async/await to load data from a URL
  • Rendering API response data as dynamic HTML cards
Quick Check

1. What format do most APIs return data in?

AHTML
BJSON
CCSV

2. What does await response.json() do?

ASends a new HTTP request
BParses the response body as JSON into a JavaScript object
CConverts JavaScript to JSON string

3. Why use try/catch with fetch()?

ATo handle network errors and bad HTTP responses gracefully
BTo make fetch() run faster
CIt is required syntax for all async functions

4. What does the async keyword do to a function?

AMakes it run in a separate thread
BMakes it return a Promise and allows use of await inside it
CMakes it execute immediately