Socket
Socket
Sign inDemoInstall

axios-concurrency

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    axios-concurrency

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


Version published
Weekly downloads
8.9K
decreased by-9.15%
Maintainers
1
Install size
396 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 19 Jan 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc