I am working on a project where I need to get related data from a server for 1 million different data points. If I try to make concurrent requests using a loop and make an array of promises and resolve the promise when I have received all the data through Promise.all I get an error ERR_INSUFFICIENT_RESOURCES.
{
...
var arr = [];
for(var i = 0; i < data.length; i++){
arr.push(getData(data[i]);
}
Promise.all(arr).then(doSomething);
}
function getData(data) {
var url = '/url&data=' + data;
return fetch('url');
}
How can I get all the data from the server for all the data points in the least amount of time and without running into errors? I do not wish to make serial requests as that would take a very long time.