I am facing an issue where I cannot seem to match a member (from the members array) with an officer (from the officers array), even when using the exact known value. There seems to be something missing in my implementation.
https://i.sstatic.net/VLM8o.png
getClanMemberInfo() {
this.clanMemberInfo = [];
console.log(this.clan.members);
console.log(this.clan.officers);
for (var i = 0; i < this.clan.members.length; i++) {
firebase
.firestore()
.collection("profiles")
.doc(this.clan.members[i])
.get()
.then(profile => {
var info = profile.data();
console.log(this.clan.officers['sJUZKKhLDvPDBWPILdzCN9waFpb2'])
if (this.clan.officers[this.clan.members[i]]) {
console.log("Hi officer");
info.officer = true;
} else {
console.log("BAT");
info.officer = false;
}
this.clanMemberInfo.push(info);
});
}
}
Even though I have provided the exact value to check, it still shows as undefined in the console logs. However, the earlier console logs show that they are not empty.
I am puzzled as to why a straightforward comparison is failing.
https://i.sstatic.net/ZQnzv.png
for (var i = 0; i < this.clan.members.length; i++) {
firebase
.firestore()
.collection("profiles")
.doc(this.clan.members[i])
.get()
.then(profile => {
var info = profile.data();
for (var o = 0; o < this.clan.officers.length; o++) {
console.log(this.clan.officers[o]);
console.log(this.clan.members[0]);
if (this.clan.officers[o].toString() === this.clan.members[i]) {
console.log("Hi officer");
info.officer = true;
} else {
console.log("BAT");
info.officer = false;
}
}
this.clanMemberInfo.push(info);
});
}
}