Hi, I need to remove the "users" variable from this function and from the for loop, I thought about using promises but I'm new to that and I can't find the way around it
var ids = [
"RtSG7NApoda9ycDRd7vm",
"TnT9XOXnkD1Ra5ROJERR",
"55fAOlOlejE3v0EUU4z9"
];
var users = [];
for(var i = 0; i < ids.length; i++){
getData(ids[i]).then(function (data) {
users.push(data);
});
}
In this case it is necessary to create a promise queue, using the method
all
of thePromise
.Documentation Promise.all()
To carry out the procedure, the following is necessary: