axios-concurrency
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/axios-concurrency package

1.0.4 • Public • Published

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

/axios-concurrency/

    Package Sidebar

    Install

    npm i axios-concurrency

    Weekly Downloads

    8,828

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    6.11 kB

    Total Files

    4

    Last publish

    Collaborators

    • bernawil