axios-header-interceptor

1.0.1 • Public • Published

axios-header-interceptor

Download Status Sponsor on GitHub

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')
)

Package Sidebar

Install

npm i axios-header-interceptor

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

5.05 kB

Total Files

5

Last publish

Collaborators

  • compwright