← Over the wire · all materialsPlayground
fetch

fetch sandbox

A script, a preview, a console and a Network tab. Requests to /api/… go to the Harbour Market API (documented in api.html); the server restarts on every run, so data you POST lasts until the next one. Click a row in the Network tab to see its headers and body.

Try this

  1. Change the URL to /api/stalls/pizza. Does fetch throw? What does response.ok say?
  2. POST a review to /api/stalls/taco-bike/reviews and log the created review. Then GET the reviews in the same script.
  3. Send body: { author: "Ana" } without JSON.stringify. Open the request in the Network tab: what was actually sent?
  4. Wrap the fetch in try … catch, then add { signal: AbortSignal.timeout(100) }. What's the error's name?