What this thread does
Do first: use axios.isAxiosError(error) and check error.response before reading error.response.data or error.response.status.
Short answer
As of November 2026, Axios 1.21.1 documents that responseType has no default value; select "json" explicitly when the API contract is JSON. A rejected HTTP response, an unreadable network response and a request configuration failure need different branches. The tagged status validator returns status >= 200 && status < 300 (tagged defaults).
Choose / don't choose
- Local catch: choose for endpoint-specific validation fields and user messages; don't lose the original status/body before making that decision.
- Response interceptor: choose for shared logging or one consistent error envelope on a custom instance; don't turn rejection into success unintentionally. Return
Promise.reject(error)to preserve rejection (interceptors). These are design choices based on the callback scope. - Custom accepted status: choose for a deliberate response contract; don't accept every response just to avoid handling failures.
Not for: Node.js response double-send failures; see node-err-http-headers-sent-write-after-end-diagnostic.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
validateStatus | Tagged function returns status >= 200 && status < 300; guide example status < 500 resolves only if the status code is less than 500 | 1.21.1 | defaults, error guide |
responseType | Select "json" as the response data type; omitted has no default value | 1.21.1 | release, config |
transitional.silentJSONParsing | Set false together with responseType: "json" to reject malformed JSON instead of silently returning raw text | 1.21.1 | tagged transform, config |
validateStatus: null | Resolves every HTTP status; use only if every response is handled explicitly | Current config docs | config |
axios.interceptors.response.use | Fulfilled callback handles accepted statuses; rejected callback should reject again when it has not recovered | Current interceptor docs | interceptors |
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ERR_NETWORK | No readable response; browser CORS can hide a status visible in developer tools | Inspect the browser console and server CORS headers, including on error responses; do not fabricate an HTTP status | error guide, April 24, 2026 maintainer explanation |
ERR_BAD_RESPONSE | Server failure or strict JSON parsing failure | Inspect available response/status; distinguish invalid JSON from a legitimate JSON error body | error guide, transform |
ERR_INVALID_URL | Request URL is malformed | Correct the URL/configuration before retrying; this is not a server error payload | config |
Diagnostic: error.response is undefined
error.response: an HTTP response is available; handleerror.response.data,.status, and.headers.- Only
error.request: request was sent but no response is readable; investigate transport, timeout and browser policy. - Final
else: inspecterror.messageand request configuration for setup failures. Guard non-Axios thrown values separately (official branches).
Missing
responseType: "json"cannot make an HTML proxy error into a valid object. Validate the body shape before reading application fields.- A network error has no authoritative server status; jasonsaayman's CORS explanation shows why the JS layer receives an opaque network error with no status code when the browser blocks a response due to CORS.
Checked
2026-11-12; Axios 1.21.1 November 9 release, tagged defaults, error/config/interceptor references and IftekharHakimK's issue with jasonsaayman's dated resolution read. No API request executed.
Started from a post by @Axios, packaged by the editor. Original post