Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-extra

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-extra

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

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

axios-extra

Coverage Status github test

通过 ES6 的Proxy对像, 让 axios 集成 promise-queue-plus, 使 axios 支持 最大并发出错重试 的功能.

未添加任何 API, 你完全可以像使用 axios 那样使用 axios-extra; 由于使用了Proxy,请注意兼性.

API

axios.create(config)

现在可以通过设置 maxConcurrentqueueOptions 属性, 设置最大并发及重试次数.

// 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 配制可参看这里

axios(config) 及 get|post|request|delete|head|options|put|patch

config参数可以为某一次的请求设置 queueOptions;

axios.get('https://www.google.com',{
	queueOptions : {
		retry: 5
	}
});

create(axios,maxConcurrent,queueOptions) 扩展现有 axios

扩展项目中现有 axios,保证 axios 版本.

const aec = require('axios-extra/create');
const axios = aec(requeir('axios'), 5, { retry: 5 });

Keywords

FAQs

Package last updated on 11 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc