← Lesson
BitWithBite
Full-Stack · Quick Reference

Lesson 18 — Fetch API & Async/Await Cheat Sheet

Full-Stack
In one line: fetch() returns a Promise; async/await lets you write asynchronous code top-to-bottom, wrapped in try/catch.

Key Ideas

1fetch(). Returns a Promise resolving to a Response.
2await. Pauses until the Promise resolves.
3try/catch. Catches network/parse errors safely.
4res.json(). Parses the response body as JSON.
5Promise.all(). Runs multiple requests in parallel.

Example

async function getUser(id) { try { const res = await fetch(`/api/users/${id}`); if (!res.ok) throw new Error('Failed'); return await res.json(); } catch (err) { console.error(err); } }