Fetch and send data between the browser and servers
Please read:
- Identifying resources on the Web
- An overview of HTTP
- HTTP Messages
- HTTP request methods
- HTTP response status codes
- Synchronizing with Effects
- fetch()
Supplemental reading:
- Text-based protocol used almost everywhere, easy to debug
- Single request / response, stateless, thus very reliable
- scheme: http / https
- host / authority
- port, default based on scheme: 80 / 443
- path
- query
- hash / fragment, not sent!
- Request Start line: method, URL, version
- Response status line: version, status code, status text
- Headers
- Body
- POST - create
- GET - read, cachable
- PUT - update, idempotent
- DELETE - delete, idempotent
- PATCH - partial update, not idempotent
- fetch
- response: ok, status, statusText, json
- url encoding, URL, URLSearchParams
- JSON serialization: parse(), stringify()
- Base64 (ASCII) encoding for binary data: btoa(), atob()
- event handler
- useEffect, dependencies, cleanup
- loading indicators
- error reporting
- browser caching, app caching, cache invalidation
- manual type definition
- OpenAPI, type generation
- run-time type validation
- mock fetch
- simulating errors
- Browser Developer Tools
- requestbin.com