A rate limit for axios: set how many requests per interval should perform immediately, other will be delayed automatically.
yarn add axios-rate-limit
import axios from 'axios';
import rateLimit from 'axios-rate-limit';
// sets max 2 requests per 1 second, other will be delayed
const http = rateLimit(axios.create(), { maxRequests: 2, perMilliseconds: 1000 });
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
Since 2010 lead my own software development company Cifronomika. We doing Ruby on Rails and JavaScript development. Feel free to contact