While running XMLHttpRequest inside .map()
, everything operates smoothly.
list.map(function(file) {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {}
xhr.onerror = function () {}
xhr.upload.addEventListener('progress', (e) => {}
xhr.send(file);
}
The issue lies in the fact that this loop initiates all xhr.send()
calls at the same time.
What measures should I take to ensure these iterations happen sequentially?
How can I make sure one request completes before the next one starts?