Reference

Errors

AxiosError codes parsed from the pinned source, and what each code means.

A failed request rejects with an AxiosError. It extends the native Error and adds code, config, request and response.

import axios, { AxiosError } from "axios";

try {
  await axios.get("https://api.example.com/nope");
} catch (err) {
  const e = err as AxiosError;
  if (e.response) {
    console.error(e.response.status, e.response.data);
  } else if (e.request) {
    console.error("no response", e.code);
  }
}

Error codes

Parsed from lib/core/AxiosError.js in the pinned commit e6b79d9cef79.

CodeMeaning
ERR_BAD_OPTIONsee the axios error guide
ERR_BAD_OPTION_VALUEsee the axios error guide
ERR_BAD_REQUESTsee the axios error guide
ERR_BAD_RESPONSEsee the axios error guide
ERR_CANCELEDsee the axios error guide
ERR_DEPRECATEDsee the axios error guide
ERR_FORM_DATA_DEPTH_EXCEEDEDsee the axios error guide
ERR_FR_TOO_MANY_REDIRECTSsee the axios error guide
ERR_INVALID_URLsee the axios error guide
ERR_NETWORKsee the axios error guide
ERR_NOT_SUPPORTsee the axios error guide

Predicates

HelperReturns
axios.isAxiosError(payload)true when the payload is an AxiosError.
axios.isCancel(value)true for errors produced by cancellation.