why-did-you-fetch patches fetch/XMLHttpRequest in development and tells you exactly which call site made a request your app didn't need to — the same idea as why-did-you-render, aimed at your network tab instead of your render tree.
Pick a pattern below. It runs the real init() from the published why-did-you-fetch package against a mock network layer (nothing real leaves your browser) and shows you exactly what you'd see in your own console.
Five detectors, run on every patched request. The first two are near-certain; the other three name an observable pattern, not a proven dependency.
| Detector | Fires when | Confidence |
|---|---|---|
duplicate-inflight |
The exact same request is issued again before the first one has settled. | high |
duplicate-recent |
The exact same request repeats shortly (default 2s) after an identical one just finished. | high |
sequential-chain |
3+ requests fire back-to-back with almost no gap between one settling and the next starting. | heuristic |
rapid-calls |
5+ calls to the same path with a different query string each time fire within 1s — a search box refetching on every keystroke. | heuristic |
n-plus-one |
5+ calls to the same route shape (id-like segments collapsed, e.g. /api/users/:id) each to a different URL fire within 500ms — a list fetching each row's data individually. |
heuristic |
One call, as early as possible. It no-ops automatically when NODE_ENV === 'production'.