axios-header-interceptor
v1.0.1
Published
A tiny axios interceptor for adding request headers
Downloads
21
Maintainers
Readme
axios-header-interceptor
A tiny axios interceptor for adding request headers.
Installation
With NPM:
npm install --save axios-header-interceptor
With Yarn:
yarn add axios-header-interceptor
Example usage
import axios from 'axios'
import addHeader from 'axios-header-interceptor'
const client = axios.createClient()
client.interceptors.response.use(
addHeader({ 'X-Requested-With': 'myapp/axios' })
)
Adding OAuth 2.0 access token header
import axios from 'axios'
import { addOauthHeader } from 'axios-header-interceptor'
const client = axios.createClient()
// Sets the `Authorization: Bearer ACCESS_TOKEN` header
client.interceptors.response.use(
addOauthHeader('ACCESS_TOKEN')
)