1.0.0-alpha.2 • Published 4 years ago
axios-queue-manager v1.0.0-alpha.2
AxiosQueueManager
Description
AxiosQueueManager is a wrapper of axios which enables you to enqueue axios requests and run them in a pipeline.
Instalation
npm install axios-queue-manager
for npm users and yarn add axios-queue-manager
for yarn users.
Usage
import axios from 'axios-queue-manager';
axios.get('https://endpoint.test.net').then((response) => {
console.log('Hey look, I am getting a response using AxiosQueueManager :D');
});
axios.post('https://endpoint.test.net', {}).then((response) => {
console.log('Hey look, I am posting something and getting a response using AxiosQueueManager :D');
});
Customizing
If you want to customize the queue length, you can create your own AxiosQueueManager and use it as a client, just like below.
import { AxiosQueueManager } from 'axios-queue-manager';
const client = new AxiosQueueManager({ queueSize: 10 });
client.get('https://endpoint.test.net').then((response) => {
console.log('Hey look, I am getting a response using AxiosQueueManager :D');
});
Configuration
As showed previously, you can create and configure your own AxiosQueueManager instance, which can receives an object with the following configs.
Key | Optional | Default Value | Type | Description |
---|---|---|---|---|
queueSize | True | 10 | Number | Represents the queue's maximum size |
client | True | axios.default | AxiosInstance | Can be set to use a custom axios instance in the requests |
1.0.0-alpha.2
4 years ago