@fatgy/is-error-code-equal
v2.0.4
Published
Check error code from axios error response
Downloads
88
Readme
is-error-code-equal
Check error code from api.
Install
npm install @fatgy/is-error-code-equal
Usage
ex. api response
{
"status": {
"code": 401,
"message": "Can not process entity"
},
"error": {
"code": 10000,
"message": "Can not process entity",
"errors": []
}
}
import {isErrorCodeEqual} from '@fatgy/is-error-code-equal';
isErrorCodeEqual(error, 10000);
//=> true
isErrorCodeEqual(error, 10001);
//=> false
API
isErrorCodeEqual(error, code)
error
Type: AxiosError
code
Type: number