@axios-plugin/throttle
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@axios-plugin/throttle

限制axios发送请求的频率,避免过多的请求对服务器造成负担或浪费带宽资源。

安装

yarn add @axios-plugin/throttle

使用

import { ThrottlePlugin } from '@axios-plugin/throttle'

axiosInstance = 
  pluginify(axios.create() as AxiosStatic).use(new ThrottlePlugin({ maxTime: 1000 }).generate()

参数

new ThrottlePlugin() //默认是 500ms 内,不会重发请求
new ThrottlePlugin({ maxTime: 1000 }) // 1s

注意

在使用 TimeoutPlugin 时,首先需要使用 pluginify 将 axios变成基于插件的请求库. pluginify 内置在 @axios-plugin/core 中.

Package Sidebar

Install

npm i @axios-plugin/throttle

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

8.5 kB

Total Files

6

Last publish

Collaborators

  • mengqiuleo