← JavaScript learning path
JavaScript · Module 10 of 10

Fetch, JSON and modern JS

Call APIs with fetch, work with JSON, and organise code with modules.

📖 Key ideas

  1. fetch(url) requests data from a server and returns a promise.
  2. APIs usually send JSON; res.json() parses it into objects.
  3. JSON.stringify() turns objects into JSON text to send.
  4. ES modules: export from one file, import in another.
  5. Check res.ok before trusting the data.
💡 Real-life example: fetch is like sending a letter to an office and getting a reply in a standard form (JSON) you can read easily.
fetchMakes HTTP requests from JavaScript
JSONText format for data exchange
exportShares code from a module
res.okTrue when the response status is 200-299