HTTP Requests and Fetch
- fetch. The fetch function sends an HTTP request and returns a promise of the response: the browser’s built-in network door.
- Checking responses. fetch resolves even for a 404: you must check response.ok before trusting the body.
- Sending data. A POST sends a body: stringify your object and set the Content-Type header to application/json.
JSON and External APIs
- JSON. JSON is the text format APIs speak: objects, arrays, strings, numbers and booleans, with every key double-quoted.
- Parsing and stringifying. JSON.parse turns response text into live objects; JSON.stringify goes the other way: both throw on invalid input.
- API contracts. An API’s documented shapes are a contract: code that checks fields exist survives the day the server changes.
Streaming and Realtime Concepts
- Streams. A stream delivers data in chunks as it arrives, so a page can show the first bytes before the last exist.
- WebSockets. A WebSocket holds one connection open both ways, letting the server push messages the moment something happens.
- Polling versus push. Polling asks the server again and again on a timer; push connections invert that so news travels instantly.
Before and after this level
- Before: Level 10: Browser JavaScript: DOM and Events, Forms and User Interaction, Browser APIs and Storage.
- Next: Level 12: Advanced Language Patterns: Iterators and Generators, Symbols, Maps, Sets and Advanced Collections, Functional and Declarative Patterns.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does JavaScript Level 11: Networking & Data cover?
HTTP Requests and Fetch, JSON and External APIs, Streaming and Realtime Concepts: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 10: Browser JavaScript, which covers DOM and Events, Forms and User Interaction, Browser APIs and Storage.