ac
axios-concurrency
npm i axios-concurrency
ac

axios-concurrency

Concurrency manager for Axios. Gives control of how many requests an axios instance makes concurrently. Useful for dealing with rate limiting. Implemented using interceptors

by Bernardo Wilberger

1.0.4 (see all)License:MITTypeScript:Not Found
npm i axios-concurrency
Readme

Axios Concurrency Manager

Get control of concurrent requests of any axios instance. Implemented using axios interceptors

Installing

$ npm install axios-concurrency

Example

const { ConcurrencyManager } = require("axios-concurrency");
const axios = require("axios");

let api = axios.create({
  baseURL: "http://mypublicapi.com"
});

// a concurrency parameter of 1 makes all api requests secuential
const MAX_CONCURRENT_REQUESTS = 5;

// init your manager.
const manager = ConcurrencyManager(api, MAX_CONCURRENT_REQUESTS);

// requests will be sent in batches determined by MAX_CONCURRENT_REQUESTS
Promise.all(manyIds.map(id => api.get(`/test/${id}`)))
  .then(responses => {
    // ...
  });

// to stop using the concurrency manager.
// will eject the request and response handlers from your instance
manager.detach()

License

MIT

Downloads/wk

5.1K

GitHub Stars

57

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

4

OPEN ISSUES

2

OPEN PRs

2
VersionTagPublished
1.0.4
latest
2yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate