I faced an issue with this promise. After forEach with function that returns object of users, the variable of arrays (clients) becomes empty ( [] ). Ngl I don't have a single clue how to solve this problem. Thanks for your time :))
function getAdminUsers(adminGroups) {
return new Promise(async (resolve) => {
try {
var clients = new Array();
console.log(adminGroups);
await adminGroups.forEach(async (group) => {
clients[group] = await teamspeak.serverGroupClientList(group);
});
console.log('CLIENTS', clients);
resolve(clients);
} catch (error) {
handleServerQueryError(error);
}
});
}
adminGroups array:
module.exports = {
adminGroups: [6, 277, 14, 18, 17, 16, 13, 528, 568],
};
the terminal output:
New user connected from 188.146.229.188
[
6, 277, 14, 18,
17, 16, 13, 528,
568
]
CLIENTS []