axios-error

Axios error wrapper that aim to provide clear error message to developers

axios-error downloads axios-error version axios-error license

axios-errorSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on axios-error's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of axios-error](https://npm-compare.com/img/npm-trend/THREE_YEARS/axios-error.png)](https://npm-compare.com/axios-error#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on axios-error's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of axios-error](https://npm-compare.com/img/github-trend/axios-error.png)](https://npm-compare.com/axios-error)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
axios-error5,5851,929-145 years agoMIT

README for axios-error

axios-error

Axios error wrapper that aim to provide clear error message to developers

Installation

npm i --save axios-error

or

yarn add axios-error

Usage

const AxiosError = require('axios-error');

// You can construct it from the error thrown by axios
const error = new AxiosError(errorThrownByAxios);

// Or with an custom error message
const error = new AxiosError(message, errorThrownByAxios);

// Or construct it from axios config, axios request and axios response
const error = new AxiosError(message, { config, request, response });

Calling console.log on the error instance returns the formatted message. If you'd like to get the axios request, response, or config, you can still get them via the following keys on the error instance:

console.log(error); // formatted error message
console.log(error.stack); // error stack trace
console.log(error.config); // axios request config
console.log(error.request); // HTTP request
console.log(error.response); // HTTP response