HTTP
http
Community
Why I Stopped Mocking `fetch` and Reached for MSW
The two-handler MSW setup I drop into every Vitest project. Pattern-matched URL routing, typed JSON responses, and per-test overrides without re-importing the server.
The Fetch Wrapper I Keep in Every Project
My zero-dep `apiFetch` for Node and the browser. Adds a per-request timeout, retries with jittered backoff on 5xx and network failures, parses JSON, and attaches an auth token without leaking it into errors.
A Server-Sent Events Consumer That Reconnects
The Node-friendly SSE client I write whenever the browser `EventSource` is the wrong tool. Parses the line protocol by hand, resumes from `Last-Event-ID`, and applies bounded backoff between retries.
Error Handling in REST APIs: The Shape I Settled On
RFC 7807 plus a code, requestId, errors array, and documentationUrl. The eight fields earning their keep, the status codes everyone confuses, and what changed my mind across four APIs.
CDN 101: Edge Caches, Origin Shields, and Cache Keys
The cache key matters more than the TTL. Origin shield is a cheap config win. Most CDN incidents are key bugs, not capacity bugs.
API Versioning Strategies Without the Pain
Pick a versioning strategy on the day you ship the first version. URI versioning is the safe default, calendar dating is the gold standard, and your first release IS a contract.
