Registry / testing / axios-request-throttle

axios-request-throttle

JSON →
library1.0.0jsnpmunverified

A lightweight rate-limiting utility for axios that throttles request-per-second rate globally without requiring a new axios instance. Version 1.0.0 is the latest stable release. Unlike alternatives like axios-throttled, it applies throttling directly to the global axios object, so all axios calls in the project are automatically rate-limited without changing imports. Ships TypeScript type definitions. Requires axios as a peer dependency with any version. Useful for API clients to avoid hitting rate limits.

npm install axios-request-throttle
INSTALL
IMPORT
SIG · AXIOS-REQUEST-THRO
A
axios-request-throttle
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

axiosThrottle
import axiosThrottle from 'axios-request-throttle'
const axiosThrottle = require('axios-request-throttle')
The package exports a default function. ESM import is recommended; TypeScript types included.
use
import axiosThrottle from 'axios-request-throttle'; axiosThrottle.use(axios, { requestsPerSecond: 5 })
import { use } from 'axios-request-throttle'
The 'use' method is attached to the default import, not a named export.
default import
import axiosThrottle from 'axios-request-throttle'
import * as axiosThrottle from 'axios-request-throttle'
Namespace import may work but default import is the intended pattern.

Demonstrates applying global throttle of 2 requests per second to axios and making concurrent requests.

import axios from 'axios'; import axiosThrottle from 'axios-request-throttle'; async function run() { axiosThrottle.use(axios, { requestsPerSecond: 2 }); const urls = ['https://api.example.com/1', 'https://api.example.com/2', 'https://api.example.com/3']; const results = await Promise.all(urls.map(url => axios.get(url))); results.forEach(r => console.log(r.status)); } run().catch(console.error);
Debug
Known issues
gotchaThrottle is applied globally to the imported axios instance. If you have multiple axios instances or use different base URLs with different rate limits, this module cannot differentiate.
fix
Use separate axios instances or a per-instance throttling solution like axios-throttled.
affects: >=1.0.0
gotchaThe throttle works by delaying requests. If the rate limit is set too low and requests pile up, memory usage may increase as requests are queued indefinitely.
fix
Set a reasonable requestsPerSecond value and consider adding a timeout or limiting total queued requests.
affects: >=1.0.0
gotchaThe module does not provide any built-in error handling for requests that fail due to rate limiting by the server; it only throttles the client side.
fix
Implement retry logic with exponential backoff in your axios request interceptor or use a library like axios-retry.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot read property 'use' of undefined
Trying to call use on the default export without importing it correctly, e.g., using a named import.
fix
Use: import axiosThrottle from 'axios-request-throttle'; then axiosThrottle.use(...)
Requests are not being throttled
The axios instance passed to use() might be a different instance than the one used for making requests, or the throttle configuration is incorrect.
fix
Ensure you pass the same axios object you use for requests. Check that requestsPerSecond is a positive number.
TypeError: axiosThrottle is not a function
Importing the module in a CommonJS environment without using default import correctly.
fix
Use: const axiosThrottle = require('axios-request-throttle').default; or switch to ESM imports.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency required to attach interceptors and throttle requests.
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
axios-request-throttle — npm install axios-request-throttle · libregistry