I fetch a list of users from aws cognitio, that works perfectly.
Now I want to iterate over this array and remove those which don't match to a Client ID, that does not work properly.
what is my failure in this case?
My code looks like this:
this.awsSDKAuth().listUsers(params, (err, data) => {
if (err) console.log(err, err.stack); // an error occurred
else {
let userArray = data.Users.slice(0);
console.log(userArray);
userArray.forEach((user,index) => {
user.Attributes.forEach(attr => {
if(attr.Name === "custom:client" && attr.Value !== clientId){
userArray.splice(index,1);
console.log(userArray);
}
}
)});
console.log(userArray);
this.setState({
users: userArray
})
}
});
Thanks
In this case I got two useres one with clientID = 36 and one with clientID = 35.
only the one with 36 should be displayed
Question: Should I do this recoursive? Breac the foreach when one is found and start again? maybe of wrong indexing?
