# With Yarn
yarn add simple-axios-interceptors
# With NPM
npm install simple-axios-interceptors
import axios from 'axios';
import connect from 'simple-axios-interceptor';
const instance = axios.create({
baseURL: 'https://api.twitter.com/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
connect(instance, 'twitter')
.onRequest((label, { request }) => {
...
})
.onRequestError((label, { error }) => {
...
})
.onResponse((label, { response }) => {
...
})
.onResponseError((label, { error }) => {
...
});
instance
- Axios Instancelabel
- Default:null
Instance Label
callback
- Passes inlabel
and{ error }
callback
- Passes inlabel
and{ error }
callback
- Passes inlabel
and{ error }
callback
- Passes inlabel
and{ error }