I get document from Firestore, it's work:
this.sub = this.beluginService.getBeluginById(this.personId)
.subscribe((documentSnapshot: firebase.firestore.DocumentSnapshot) => {
console.log(documentSnapshot.data());
}
My service:
getBeluginById(id: string) {
return this.afs.collection('belugin').doc(id).get();
}
In console.log I get one object:
{ id: "ya1jibU2pZx1niGiuAmp"
qwCF: [0, 0, 2, 0, 0, 6, 2]
qwCO: [0, 0, 0, 0, 2, 0, 0]
qwIMP: [10, 0, 2, 2, 2, 4, 0]
qwME: [0, 4, 0, 4, 2, 0, 0]
qwPL: [0, 0, 0, 0, 0, 0, 0]
qwRI: [0, 2, 2, 2, 2, 0, 0]
qwSH: [0, 0, 0, 0, 0, 0, 0]
qwTW: [0, 4, 4, 2, 2, 0, 8] }
But when I try to get object properties (etc id, qwCF):
this.sub = this.beluginService.getBeluginById(this.personId)
.subscribe((documentSnapshot: firebase.firestore.DocumentSnapshot) => {
this.id = documentSnapshot.data().id;
this.qwCF = documentSnapshot.data().qwCF;
}
I can't get data() properties.... My VCCode shows a method data() call error. Why?
If documentSnapshot.data()
work in the log maybe takind the data from it it will be better:
const data = documentSnapshot.data();
this.id = data.id
Depending on the ECMA version maybe
this.id = data["id"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With