question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does Axios have a way to queue X simultaneous requests?

See original GitHub issue

Let’s say I need to do 20 ajax requests, and my server supports doing 3 at a time.

Does Axios have a way to queue up the 20 requests, and run 3 concurrently?

It doesn’t seem like .all() or .spread() support this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

44reactions
lukas-shawfordcommented, Aug 31, 2017

I was able to achieve this using another helper library cwait (in combination with axios):

import axios from 'axios';
import { TaskQueue } from 'cwait';

const MAX_SIMULTANEOUS_DOWNLOADS = 6;

const urls = [/* Array of URLs to download... */];

const queue = new TaskQueue(Promise, MAX_SIMULTANEOUS_DOWNLOADS);
const results = await Promise.all(urls.map(queue.wrap(async url => await axios.get(url))));
12reactions
rubennortecommented, Aug 12, 2017

You can use Bluebird.map to control the concurrency of any Promise-based code. See http://bluebirdjs.com/docs/api/promise.map.html

This is out of the scope of Axios.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using axios.all to make concurrent requests - LogRocket Blog
axios.all is a helper method built into Axios to deal with concurrent requests. Instead of making multiple HTTP requests individually, ...
Read more >
How to send multiple requests using axios - Storyblok
Let us start with a small task and sending one request using Axios itself. First, we import axios and define the API/URL we...
Read more >
Handle Multiple Requests Using Axios Interceptor While ...
Whenever login API expires authentication token so we simply refresh it through Interceptor(request and response).
Read more >
Axios multiple request on interceptor - Stack Overflow
My question is let say I have three requests happening concurrently and I don't have the token, the interceptor calling the getUserRandomToken ...
Read more >
How to Perform HTTP Requests with Axios – A Complete Guide
Fetch API and Axios are the two most common native Javascript alternatives for sending multiple requests right now. However, Axios GitHub has an ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found