Skip to content

compwright/axios-header-interceptor

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published