D
D
Desiga2019-12-14 18:32:08
JavaScript
Desiga, 2019-12-14 18:32:08

How to bulk send requests from the browser?

Hello!
I work with the react + redux + redux-thunk + axios stack
There is a request, an object is sent in the request, the object has a key with an array of about 300000 in length. It is
necessary to split this array into parts (I plan through array.slice). And send 5k requests, a pack of 4 with a 3 second delay, so that the server has time to give answers.
Could you tell me how to implement this task correctly? Through a for loop with Promise.all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
abberati, 2019-12-14
@abberati

Promise.all will run all requests at once. Google promise sequence, or you will find a library, or write it by hand.

A
Alexander Taratin, 2019-12-15
@Taraflex

Bursts are not as efficient as a "multi-threaded" queue with a constant number of concurrent tasks.
https://github.com/sindresorhus/p-map

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question