https://github.com/compwright/axios-header-interceptor
https://github.com/compwright/axios-header-interceptor
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/compwright/axios-header-interceptor
- Owner: compwright
- License: mit
- Created: 2022-10-05T20:24:48.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2026-01-22T19:23:01.000Z (2 months ago)
- Last Synced: 2026-01-23T12:24:14.150Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.48 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# axios-header-interceptor
[](https://www.npmjs.com/package/axios-header-interceptor)
[](https://github.com/sponsors/compwright)
A tiny [axios](https://www.npmjs.com/package/axios) interceptor for adding request headers.
## Installation
With NPM:
```bash
npm install --save axios-header-interceptor
```
With Yarn:
```bash
yarn add axios-header-interceptor
```
## Example usage
```javascript
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
```javascript
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')
)
```