axios-rate-limit

axios 限速。「Rate limit for axios」

Github星跟踪图

axios-rate-limit

npm version
npm downloads
Build Status

A rate limit for axios: set how many requests per interval should perform immediately, other will be delayed automatically.

Installing

yarn add axios-rate-limit

Usage

import axios from 'axios';
import rateLimit from 'axios-rate-limit';

// sets max 2 requests per 1 second, other will be delayed
// note maxRPS is a shorthand for perMilliseconds: 1000, and it takes precedence
// if specified both with maxRequests and perMilliseconds
const http = rateLimit(axios.create(), { maxRequests: 2, perMilliseconds: 1000, maxRPS: 2 })
http.getMaxRPS() // 2
http.get('https://example.com/api/v1/users.json?page=1') // will perform immediately
http.get('https://example.com/api/v1/users.json?page=2') // will perform immediately
http.get('https://example.com/api/v1/users.json?page=3') // will perform after 1 second from the first one

// options hot-reloading also available
http.setMaxRPS(3)
http.getMaxRPS() // 3
http.setRateLimitOptions({ maxRequests: 6, perMilliseconds: 150 }) // same options as constructor

A bit of advertising :-)

Since 2010 run my own software development company Cifronomika. We doing Ruby on Rails and JavaScript development. Feel free to contact

主要指标

概览
名称与所有者aishek/axios-rate-limit
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2019-04-20 19:05:46
推送于2024-08-07 14:47:33
最后一次提交2024-06-10 08:43:16
发布数17
最新版本名称1.4.0 (发布于 )
第一版名称0.0.1 (发布于 )
用户参与
星数244
关注者数2
派生数36
提交数94
已启用问题?
问题数21
打开的问题数13
拉请求数27
打开的拉请求数3
关闭的拉请求数27
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?