# @plansis/axios-auth-refresh

> Этот простой модуль обеспечивает отправку единого запроса на обновление токена даже при обработке одновременных запросов. Кроме того, он предлагает методы для последовательной интеграции запросов Axios с различными библиотеками.

Latest version **1.1.4** (published 2025-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @plansis/axios-auth-refresh
pnpm add @plansis/axios-auth-refresh
yarn add @plansis/axios-auth-refresh
bun add @plansis/axios-auth-refresh
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2025-02-19 |
| First published | 2024-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | plansis |
| Maintainers | plansis |
| Keywords | axios, refresh token, interceptor, auto refresh |

## Links

- npm: https://www.npmjs.com/package/@plansis/axios-auth-refresh
- Repository: https://github.com/plansis1/axios-auth-refresh
- Homepage: https://github.com/plansis1/axios-auth-refresh#readme
- Issues: https://github.com/plansis1/axios-auth-refresh/issues
- npm.io page: https://npm.io/package/@plansis/axios-auth-refresh

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.7.9

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2025-02-19
- 1.1.3 — 2025-02-19
- 1.1.2 — 2024-07-31
- 1.1.0 — 2024-07-31
- 1.0.10 — 2024-06-17
- 1.0.7 — 2024-06-17
- 1.0.5 — 2024-06-17
- 1.0.4 — 2024-03-20
- 1.0.3 — 2024-03-14
- 1.0.2 — 2024-03-14
- 1.0.1 — 2024-03-14
- 1.0.0 — 2024-03-14

## README

# axios-auth-refresh

Этот простой модуль обеспечивает отправку единого запроса на обновление токена даже при обработке одновременных запросов.
Кроме того, он предлагает методы для последовательной интеграции запросов Axios с различными библиотеками.

## Basic Usage

```typescript
import axios from "axios";
import { axiosAuthRefresh } from "@plansis/axios-auth-refresh";

const axiosInstance = axios.create({
  withCredentials: true,
  baseURL: "https://example.com/api",
});

const handleRefreshAuthCall = async () => {
  const response = await axiosInstance.post<TData>(
    "/refresh",
    {},
    { skipAuthRefresh: true }
  );
  return response;
};

const onRefreshSuccess = (res: AxiosResponse<TData>) => {
  console.log("success:", res);
};

const onRefreshError = (err: AxiosError<TError>) => {
  console.log("error:", err);
};

axiosAuthRefresh<TData, TError>({
  axiosInstance,
  refreshAuthCall: handleRefreshAuthCall,
  onSuccess: onRefreshSuccess,
  onError: onRefreshError,
  options: {
    statusCodes: [401, 403],
    retryDelayMs: 300,
    maxRetryCount: 3,
    maxCallCount: 3,
  },
});
```

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