isAxiosError() Function
Returns whether the given error is an AxiosError. Can be used to narrow the type of the error.
Signature
export declare function isAxiosError(e: any, status?: number): e is AxiosError;Example
try {
await axios.get('https://example.com/thing.txt')
return true
} catch (e: unknown) {
if (!isAxiosError(e, 404)) throw e
return false
}
Parameters
| Parameter | Type | Description |
|---|---|---|
| e | any | The error to check. |
| status | number | An expected status code to check for. If not provided, any status code will be accepted. |
| (Returns) | e is AxiosError | Whether the given error is an AxiosError. |