axios-error-handler
v1.0.1
Published
My awesome typescript library
Downloads
7
Readme
axios-error-handler
The utilities for error handling with axios.
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
License
MIT © SevenOutman