# @tqman/axios-interceptor-suite

> Useful axios interceptors

Latest version **0.3.4** (published 2023-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tqman/axios-interceptor-suite
pnpm add @tqman/axios-interceptor-suite
yarn add @tqman/axios-interceptor-suite
bun add @tqman/axios-interceptor-suite
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2023-03-11 |
| First published | 2023-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 94.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tanishq Manuja |
| Maintainers | tanishqmanuja |
| Keywords | axios, interceptors, retry, throttle, rate-limit, auth-refresh |

## Links

- npm: https://www.npmjs.com/package/@tqman/axios-interceptor-suite
- Repository: https://github.com/tanishqmanuja/axios-interceptor-suite
- Homepage: https://github.com/tanishqmanuja/axios-interceptor-suite#readme
- Issues: https://github.com/tanishqmanuja/axios-interceptor-suite/issues
- npm.io page: https://npm.io/package/@tqman/axios-interceptor-suite

## Dependencies (4)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.0
- [is-retry-allowed](https://npm.io/package/is-retry-allowed.md) ^3.0.0
- [axios-auth-refresh](https://npm.io/package/axios-auth-refresh.md) ^3.3.6
- [axios-cache-interceptor](https://npm.io/package/axios-cache-interceptor.md) ^1.0.1

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.3.4 (latest) — 2023-03-11
- 0.3.3 — 2023-03-10
- 0.3.2 — 2023-03-10
- 0.3.1 — 2023-03-10
- 0.3.0 — 2023-03-01
- 0.2.2 — 2023-03-01
- 0.2.1 — 2023-03-01
- 0.2.0 — 2023-02-28
- 0.1.3 — 2023-02-25
- 0.1.2 — 2023-02-25
- 0.1.1 — 2023-02-24
- 0.1.0 — 2023-02-24

## README

# Axios Interceptor Suite

Axios Interceptor Suite is a collection of useful interceptors to make axios experience more pleasant when working with realtime API's.

## Installation

```sh
npm i @tqman/axios-interceptor-suite # npm
pnpm i @tqman/axios-interceptor-suite #pnpm
yarn add  @tqman/axios-interceptor-suite # yarn
```

## Usage

```ts
import axios from "axios"

import { createRateLimitInterceptor,
	createRetryInterceptor,
	AxiosRateLimitRequestConfig,
	AxiosRetryRequestConfig } from "@tqman/axios-interceptor-suite"

// make your axios instance
const axiosInstance = axios.create() // ofcourse you will provide your base config

// rate limit interceptor to send at most 6 requests per 2 seconds.
// overhead request will be delayed until next interval. Make sure originator of request is slower than the rate limit on average.
const { id, eject } = createRateLimitInterceptor(axiosInstance, {
	count: 6;
	interval: 2 * 1000;
})


// retry interceptor to retry failed requests 2 times with delay of 1 second between each.
createRetryInterceptor(axiosInstance, {
	count: 2;
	delay: 1 * 1000; // delay can be function also: (retryCount) => (1 + 2 ** retryCount) * 1000
})

// make you requests (with rate limit and retry)
axiosInstance.get("https://example.com")

// make request without rate limit
axiosInstance.get("https://example.com", { bypassRateLimit: true } as AxiosRateLimitRequestConfig)

// make request without retry on failure
axiosInstance.get("https://example.com", { retry: false } as AxiosRetryRequestConfig)

// change retry config for specific request & disable rate limit
axiosInstance.get("https://example.com", { retry: { count: 5 }, bypassRateLimit: true } as AxiosRetryRequestConfig & AxiosRateLimitRequestConfig)


// eject rate limit interceptor
eject()

```

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