axios-error-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

axios-error-handler

The utilities for error handling with axios.

npm version npm downloads

Features:

  • Define error handlers based on response status code
  • Wildcards mathching a class of status codes

Install

npm i axios-error-handler

Usage

import { createErrorHandler } from "axios-error-handler"

axios.interceptors.response.use(
  null,
  createErrorHandler({
    // Runs this callback if thrown.response.status is 401
    401(thrown) {
      alert("")
    },
    // Runs this callback if thrown.response.status is 5xx
    "5xx"(thrown) {
      alert("")
    },
  }),
)

Sponsors

sponsors

License

MIT © SevenOutman

/axios-error-handler/

    Package Sidebar

    Install

    npm i axios-error-handler

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • sevenoutman