# axios-extra

> Extend "Axios"; add concurrency limits, retry, etc.

Latest version **0.0.8** (published 2023-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install axios-extra
pnpm add axios-extra
yarn add axios-extra
bun add axios-extra
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2023-10-11 |
| First published | 2019-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | cnwhy |
| Maintainers | cnwhy |
| Keywords | axios, retry, concurrent, queue |

## Links

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

## Dependencies (1)

- [promise-queue-plus](https://npm.io/package/promise-queue-plus.md) ^1.2.2

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 0.0.8 (latest) — 2023-10-11
- 0.0.7 — 2023-08-22
- 0.0.6 — 2021-03-29
- 0.0.5 — 2019-01-30
- 0.0.4 — 2019-01-23
- 0.0.3 — 2019-01-23
- 0.0.2 — 2019-01-14
- 0.0.1 — 2019-01-10

## README

# axios-extra

[![Coverage Status](https://coveralls.io/repos/github/cnwhy/axios-extra/badge.svg?branch=master)](https://coveralls.io/github/cnwhy/axios-extra?branch=master) [![github test](https://github.com/cnwhy/axios-extra/workflows/test/badge.svg?branch=master)](https://github.com/cnwhy/axios-extra/actions/workflows/test.yml)

通过 ES6 的`Proxy`对像, 让 [axios](https://github.com/axios/axios) 集成 [promise-queue-plus](https://github.com/cnwhy/promise-queue-plus), 使 `axios` 支持 **最大并发** 及 **出错重试** 的功能.

> 未添加任何 API, 你完全可以像使用 `axios` 那样使用 `axios-extra`;
> 由于使用了`Proxy`,请注意兼性.

## API

### axios.create(config)

现在可以通过设置 `maxConcurrent` 和 `queueOptions` 属性, 设置最大并发及重试次数.

```js
// axios 并发为10, 自动重试为0
const axios = require('axios-extra'); //默认最大并发 10, 重试 0;

// 创建一个 并发为1, 自动重试为3的 axios;
let axios1 = axios.create({
	maxConcurrent:1, //并发为1
	queueOptions: {
		retry:3, //请求失败时,最多会重试3次
		retryIsJump: true //是否立即重试, 否则将在请求队列尾部插入重试请求
	}
});

let {stop, start, clear} = axios1.requestQueue; // 暴露内部的队列对像，可以使用 stop start clear 等 API;
```

> 更多 `queueOptions` 配制可参看[这里](https://github.com/cnwhy/promise-queue-plus#queuepushpromisefun-args-options)

### axios(config) 及 get|post|request|delete|head|options|put|patch

`config`参数可以为某一次的请求设置 `queueOptions`;

```js
axios.get('https://www.google.com',{
	queueOptions : {
		retry: 5
	}
});
```

### `create(axios,maxConcurrent,queueOptions)` 扩展现有 `axios`

扩展项目中现有 `axios`,保证 `axios` 版本.

```js
const aec = require('axios-extra/create');
const axios = aec(requeir('axios'), 5, { retry: 5 });
```

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