# axios-header-interceptor

> A tiny axios interceptor for adding request headers

Latest version **1.0.1** (published 2024-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install axios-header-interceptor
pnpm add axios-header-interceptor
yarn add axios-header-interceptor
bun add axios-header-interceptor
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-04-28 |
| First published | 2022-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 14 |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jonathon Hill |
| Maintainers | compwright |
| Keywords | axios, api, rest, interceptor, oauth |

## Links

- npm: https://www.npmjs.com/package/axios-header-interceptor
- Repository: https://github.com/compwright/axios-header-interceptor
- Homepage: https://github.com/compwright/axios-header-interceptor#readme
- Issues: https://github.com/compwright/axios-header-interceptor/issues
- npm.io page: https://npm.io/package/axios-header-interceptor

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2024-04-28
- 1.0.0 — 2022-10-05

## README

# axios-header-interceptor

[![Download Status](https://img.shields.io/npm/dm/axios-header-interceptor.svg?style=flat-square)](https://www.npmjs.com/package/axios-header-interceptor)
[![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor&message=❤&logo=GitHub&link=https://github.com/sponsors/compwright)](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')
)
```

---
_Source: https://npm.io/package/axios-header-interceptor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
