0👍
First of all Array
values can be accessed using index
number.
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();
// you are looping using members length so use members below with index
console.log(this.clan.members[i])
// you can check if your member is an officer or not by below line
if (this.clan.officers.includes(this.clan.members[i])) {
console.log("Hi officer");
info.officer = true;
} else {
console.log("BAT");
info.officer = false;
}
this.clanMemberInfo.push(info);
});
}
}
- [Vuejs]-How can I force user to choose at least one option to go to next page Vue JS
- [Vuejs]-Vue.js – Elements not displaying
0👍
it seems to be this.clan.officers is an array of strings, not a dictionary.
so this.clan.officers[0] is defined as ‘sJUZKKhLDvPDBWPILdzCN9waFpb2’
but this.clan.officers[‘sJUZKKhLDvPDBWPILdzCN9waFpb2’] is pure gibberish.
0👍
If you want to check if a given string exists inside an array of values, you can use Array.prototype.includes()
.
isOfficer = officers.includes('sJUZKKhLDvPDBWPILdzCN9waFpb2');
- [Vuejs]-SVG Pattern doesn't change fill color
- [Vuejs]-Problem to sum optional values from v-model in vuejs
Source:stackexchange.com