I have this function, that iterates through an array of strings, where each string represents a user's UID. The function is supposed to go to each user's profile, check for their most current reputation (same like SO), and then push a map of uid and reputation to a new array.
The second array always came out empty so I've placed a few logs to check what is happening. This is my function:
candidates.forEach(async id => {
console.log('user log ' + id);
const snap2 = await db.doc('communities_data/' + community.id + '/profiles/' + id).get();
const user = snap2.data();
console.log('user ' + user);
if (user !== undefined) {
console.log(user + ' just user');
const reputation = (user.reputation as number);
candidatesWithReputation.push(new UserAndReputation(id, reputation));
} else {
console.log('user undefined ');
};
});
the first which says 'user log ' +id
always prints and it prints the id of the user as it should, so I know the first array is just fine.
But none of the other logs print. ever. My first thought was that maybe I got the path wrong? But I've checked a million times, this is the path in which a user's profile would be in my DB.
for example, this could be a path to a profile:
communities_data/hfd98HDKKhfEwe6W/profiles/bqSFS04LKJDbfhdwU
Any idea where it fails