JSFiddle - React, Tailwind, and code Playground
JavaScript
var arr = [];
var users = ["brunofin", "comster404", "ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var runRequests = function(userIndex) {
if (users.length == userIndex) {
console.log("runRequests Success", arr);
return;
}
var user = users[userIndex];
$.ajax({
url: "/echo/json",
data: { user: user },
success: function(data) {
arr.push({ user: user, index: userIndex, data: data });
runRequests(++userIndex);
},
error: function() {
console.error("runRequests Error", arguments);
}
});
};
runRequests(0);