https://github.com/jfkz/axios-concurrency-v2
https://github.com/jfkz/axios-concurrency-v2
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jfkz/axios-concurrency-v2
- Owner: jfkz
- Created: 2025-02-28T19:04:52.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-28T19:10:25.000Z (3 months ago)
- Last Synced: 2025-02-28T22:55:11.339Z (3 months ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Axios Concurrency Manager
Get control of concurrent requests of any [axios](https://github.com/axios/axios) instance.
Implemented using axios interceptors## Installing
```bash
$ npm install axios-concurrency
```## Example
```js
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