Hello,
I'm trying to populate a list of users with their roles, this is the code:
$data.user = 0;
$data.listaTratada=[];
$data.grupo = "";
for( var i = 0; $data.listaUsuariosTotal.length >= i; i++){
$data.apiGetRoles = "../API/identity/membership?p=0&c=10&f=user_id="+$data.listaUsuariosTotal[i].id+"&d=role_id";
$data.listaTratada.unshift({"grupo":$data.RolesPorUsuario[0].role_id.name,
"usuario":$data.listaUsuariosTotal[i].firstname,
"id":$data.listaUsuariosTotal[i].id});
$data.listaTratada=[];
}
when launching this code, "grupo" changes to the same value on every element on the table, "grupo" is obtained from an api call, saved on the "RolesPorUsuario" variable, is there a reason why it does this and if there a fix?
EDIT : turns out the api call where I get "grupo" doesn't update fast enough, is there any way to guarantee the api call has been made properly?