axios
semver
>=1.0.0 <2.0.0postconditions34functions11last verified2026-06-23coverage score100%Postconditions — what we check
- get · success-2xxinfoWhenresponse status is 2xxReturnsAxiosResponse object with data, status, statusText, headers, config, and request fieldsRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1]
- get · error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and validateStatus is defaultThrows
AxiosError with error.response containing the error responseRequired handlingCaller MUST catch AxiosError and check error.response.status to distinguish between client errors (4xx) and server errors (5xx).costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - get · rate-limited-429errorWhenresponse status is 429 (Too Many Requests)Throws
AxiosError with error.response.status === 429Required handlingCaller MUST either: 1. Implement exponential backoff retry logic with the Retry-After header, OR 2. Explicitly handle 429 as a terminal error and surface to the user, OR 3. Use a request queue that respects rate limits. Silently catching and ignoring 429 without retry logic is a violation.costmediumin proddegraded serviceusers seedegraded performancevisibilityvisibleSources[2] - get · network-failureerrorWhennetwork error, connection timeout, or DNS resolution failureThrows
AxiosError with error.request populated but error.response === undefinedRequired handlingCaller MUST check if error.response exists before accessing error.response.status. Network errors have error.request but NO error.response property. Code that assumes error.response is always present will crash.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - get · request-setup-errorwarningWhenerror during request setup (before request is sent)Throws
AxiosError with both error.request === undefined and error.response === undefinedRequired handlingCaller MUST handle errors where neither error.request nor error.response exist. These are configuration or setup errors.costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - post · success-2xxinfoWhenresponse status is 2xxReturnsAxiosResponse objectRequired handlingNo action required — use the returned value as needed.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[1]
- post · error-4xx-5xxerrorWhenresponse status is 4xx or 5xxThrows
AxiosError with error.responseRequired handlingCaller MUST catch AxiosError and inspect error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - post · rate-limited-429errorWhenresponse status is 429Throws
AxiosError with error.response.status === 429Required handlingFor POST requests, retry logic MUST be idempotency-aware. Either use idempotency keys or handle 429 as terminal error.costmediumin proddegraded serviceusers seedegraded performancevisibilityvisibleSources[2] - post · network-failureerrorWhennetwork error, timeout, or DNS failureThrows
AxiosError with error.response === undefinedRequired handlingCheck error.response exists before accessing error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - put · error-4xx-5xxerrorWhenresponse status is 4xx or 5xxThrows
AxiosErrorRequired handlingCaller MUST catch AxiosError and inspect error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - put · network-failureerrorWhennetwork error or timeoutThrows
AxiosError with error.response === undefinedRequired handlingCheck error.response exists before accessing error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - delete · error-4xx-5xxerrorWhenresponse status is 4xx or 5xxThrows
AxiosErrorRequired handlingCaller MUST catch AxiosError and inspect error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - delete · network-failureerrorWhennetwork error or timeoutThrows
AxiosError with error.response === undefinedRequired handlingCheck error.response exists before accessing error.response.statuscosthighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - request · error-4xx-5xxerrorWhenresponse status is 4xx or 5xxThrows
AxiosError with error.responseRequired handlingCaller MUST catch AxiosError and check error.response.status to distinguish between client errors (4xx) and server errors (5xx)costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - request · rate-limited-429errorWhenresponse status is 429 (Too Many Requests)Throws
AxiosError with error.response.status === 429Required handlingCaller MUST either: 1. Implement exponential backoff retry logic with the Retry-After header, OR 2. Explicitly handle 429 as a terminal error and surface to the user, OR 3. Use a request queue that respects rate limits. For non-idempotent methods (POST), ensure retry safety with idempotency keys.costmediumin proddegraded serviceusers seedegraded performancevisibilityvisibleSources[2] - request · network-failureerrorWhennetwork error or timeoutThrows
AxiosError with error.response === undefinedRequired handlingCaller MUST check if error.response exists before accessing properties. Network errors have error.request but NO error.response property.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - request · request-setup-errorwarningWhenerror during request setup (before request is sent)Throws
AxiosError with both error.request === undefined and error.response === undefinedRequired handlingCaller MUST handle errors where neither error.request nor error.response exist. These are configuration or setup errors (e.g., invalid URL, unsupported protocol).costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - patch · patch-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and validateStatus is defaultThrows
AxiosError with error.response containing status, headers, and bodyRequired handlingCaller MUST catch AxiosError and check error.response.status to distinguish client errors (4xx) from server errors (5xx). Do not retry 4xx without user intervention (except 408, 413, 429).costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - patch · patch-rate-limited-429errorWhenresponse status is 429 (Too Many Requests)Throws
AxiosError with error.response.status === 429Required handlingCaller MUST implement exponential backoff with the Retry-After header. For PATCH (partial updates), retrying is often safe if the operation is idempotent, but verify with the API's idempotency guarantees. Silently catching and ignoring 429 without retry is a violation.costmediumin proddegraded serviceusers seedegraded performancevisibilityvisibleSources[2] - patch · patch-network-failureerrorWhennetwork error, timeout (ETIMEDOUT/ECONNABORTED), or DNS failure (ERR_NETWORK)Throws
AxiosError with error.request populated but error.response === undefined; error.code is ETIMEDOUT, ECONNABORTED, or ERR_NETWORKRequired handlingCaller MUST check if error.response exists before accessing error.response.status. Network errors populate error.request (the raw http.ClientRequest) but NOT error.response. Code that assumes error.response is always present will crash with TypeError.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - head · head-error-4xx-5xxerrorWhenserver responds with 4xx or 5xx and validateStatus is defaultThrows
AxiosError with error.response (status, headers) but error.response.data === ''Required handlingCaller MUST catch AxiosError and check error.response.status. NOTE: error.response.data is always an empty string for HEAD responses (the server sends no body). Do not attempt to parse error body for HEAD requests.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - head · head-network-failureerrorWhennetwork error, connection timeout, or DNS failureThrows
AxiosError with error.request populated but error.response === undefinedRequired handlingCaller MUST check error.response exists before accessing it. Network errors do not populate error.response — accessing error.response.status will throw TypeError: Cannot read properties of undefined.costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisibleSources[2] - postForm · postform-error-4xx-5xxerrorWhenserver responds with 4xx or 5xx and validateStatus is defaultThrows
AxiosError with error.response containing status and bodyRequired handlingCaller MUST catch AxiosError and inspect error.response.status. File upload failures (413 Payload Too Large, 415 Unsupported Media Type, 422 Unprocessable Entity) are common and must be handled explicitly.costhighin prodimmediate exceptionusers seelost datavisibilityvisible - postForm · postform-payload-too-large-413errorWhenserver responds with 413 Payload Too LargeThrows
AxiosError with error.response.status === 413Required handlingCaller MUST handle 413 explicitly for file upload flows. Options: 1. Check file size before upload and reject files exceeding the limit. 2. Split large files into chunks and upload in parts. 3. Surface a specific error to the user ("File too large, max 10MB"). Silently catching 413 causes silent upload failure with no user feedback.costhighin prodimmediate exceptionusers seelost datavisibilitysilent - postForm · postform-network-failureerrorWhennetwork error, connection timeout, or DNS failure during uploadThrows
AxiosError with error.request populated but error.response === undefinedRequired handlingCaller MUST check error.response exists before accessing it. File uploads are more susceptible to network timeouts (large payloads). Consider setting an explicit timeout and implementing retry with resume capability.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[2] - postForm · postform-serialization-errorwarningWhenFormData serialization fails due to incompatible or circular dataThrows
AxiosError with error.code === 'ERR_BAD_REQUEST' or native TypeError from serializerRequired handlingCaller SHOULD validate data before passing to postForm. Circular references in nested objects will throw during serialization (before any network request). Custom visitor functions (config.formSerializer) that throw will surface as unhandled exceptions if not wrapped in try-catch.costmediumin prodimmediate exceptionusers seelost datavisibilityvisible - putForm · putform-error-4xx-5xxerrorWhenserver responds with 4xx or 5xxThrows
AxiosError with error.responseRequired handlingCaller MUST catch AxiosError. For file replacement flows, handle 413 (file too large) and 415 (unsupported media type) explicitly. PUT is idempotent, so retrying is safe for network failures but will replace the resource again.costhighin prodimmediate exceptionusers seelost datavisibilityvisible - putForm · putform-network-failureerrorWhennetwork error or timeoutThrows
AxiosError with error.response === undefinedRequired handlingCaller MUST check error.response exists. PUT is idempotent — retrying after network failure is safe and recommended, but verify the server has not already processed the request (check with HEAD or GET before retrying).costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[2] - query · query-error-4xx-5xxerrorWhenresponse status is 4xx or 5xx and validateStatus is defaultThrows
AxiosError with error.response containing status, headers, and bodyRequired handlingCaller MUST catch AxiosError and check error.response.status to distinguish client errors (4xx — bad query payload, unsupported QUERY method on the target endpoint, 405 Method Not Allowed) from server errors (5xx). Many servers/proxies do not yet implement QUERY and will return 405 or 501 — handle these explicitly.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - query · query-method-not-allowed-405errorWhenserver responds with 405 Method Not Allowed or 501 Not ImplementedThrows
AxiosError with error.response.status === 405 or 501Required handlingCaller MUST handle 405/501 explicitly for QUERY requests. QUERY is a newer HTTP method (still on the standards track) and many origins, CDNs, reverse proxies, and WAFs reject it. Fall back to POST + idempotency key, or surface a clear error indicating the upstream does not support QUERY. Silently catching this and retrying as POST may change resource semantics if the server treats POST as non-idempotent.costmediumin proddegraded serviceusers seeservice unavailablevisibilityvisible - query · query-rate-limited-429errorWhenresponse status is 429 (Too Many Requests)Throws
AxiosError with error.response.status === 429Required handlingCaller MUST implement exponential backoff with the Retry-After header. QUERY is safe AND idempotent per the HTTPbis draft, so retrying after 429 is safe (unlike POST/PATCH where retry safety depends on idempotency keys). Silently catching and ignoring 429 without retry logic is a violation.costmediumin proddegraded serviceusers seedegraded performancevisibilityvisible - query · query-network-failureerrorWhennetwork error, connection timeout (ETIMEDOUT/ECONNABORTED), connection refused (ECONNREFUSED), or DNS failure (ERR_NETWORK)Throws
AxiosError with error.request populated but error.response === undefined; error.code is ETIMEDOUT, ECONNABORTED, ECONNREFUSED, or ERR_NETWORKRequired handlingCaller MUST check error.response exists before accessing error.response.status. Network errors populate error.request (raw http.ClientRequest) but NOT error.response. The ECONNREFUSED constant was added in axios 1.16.0 (PR #10680) so callers can match connection-refused failures via AxiosError.ECONNREFUSED instead of string-compare on the code field. Because QUERY is safe and idempotent, retry on network failure is safe — but bound the retry budget to avoid hammering an unreachable origin.costhighin prodimmediate exceptionusers seeservice unavailablevisibilityvisible - patchForm · patchform-error-4xx-5xxerrorWhenserver responds with 4xx or 5xxThrows
AxiosError with error.responseRequired handlingCaller MUST catch AxiosError. Handle 413 (file too large) and 415 (unsupported media type) explicitly. PATCH is not guaranteed idempotent — do not blindly retry without understanding the server's idempotency semantics.costhighin prodimmediate exceptionusers seelost datavisibilityvisible - patchForm · patchform-network-failureerrorWhennetwork error or timeoutThrows
AxiosError with error.response === undefinedRequired handlingCaller MUST check error.response exists before accessing. Do not blindly retry patchForm on network failure — PATCH may not be idempotent. Use idempotency keys or check state before retrying.costhighin prodimmediate exceptionusers seelost datavisibilityvisibleSources[2]
Sources
Every postcondition cites at least one of these. Numbered to match the footnotes above.
- [1]axios-http.com/docs/res_schemahttps://axios-http.com/docs/res_schema
- [2]axios-http.com/docs/handling_errorshttps://axios-http.com/docs/handling_errors
- [3]axios-http.com/docs/api_introhttps://axios-http.com/docs/api_intro
- [4]github.com/axios/axioshttps://github.com/axios/axios/blob/v1.x/lib/core/AxiosError.js
- [5]developer.mozilla.org/en-US/docshttps://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
- [6]axios-http.com/docs/multiparthttps://axios-http.com/docs/multipart
- [7]developer.mozilla.org/en-US/docshttps://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413
- [8]github.com/axios/axioshttps://github.com/axios/axios/pull/10802
- [9]ietf.org/archive/idhttps://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-09.html
- [10]developer.mozilla.org/en-US/docshttps://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
- [11]github.com/axios/axioshttps://github.com/axios/axios/pull/10680
- [12]axios-http.com/docs/req_confighttps://axios-http.com/docs/req_config
Need a different package?
Request a profile