Example 1 — Mock response flow
Same control flow as real fetch.
JavaScript
async function load() {
const res = { ok: true, async json() { return { name: "Ada" }; } };
const data = await res.json();
console.log(data.name);
}
load();How It Works
- Pretend fetch returned res.
- Await json().
- Use the data.
