axios-error
An axios error wrapper that aim to provide clear error message to the user
Installation
npm i --save axios-error
or
yarn add axios-error
Usage
const AxiosError = require('axios-error');
const error = new AxiosError(errorThrowByAxios);
const error = new AxiosError(message, errorThrowByAxios);
const error = new AxiosError(message, { config, request, response });
Directly console.log
on the error instance will return formatted message. If you'd like to get the axios request
, response
, or config
, you can still get them via those keys on the error instance.
console.log(error);
console.log(error.stack);
console.log(error.config);
console.log(error.request);
console.log(error.response);