How to make it work okay? I need only one document from base with id.Is it possible to subscribe it? Because it returns me a Observable object:(
Here`s my code.
getByid(id){
return this.itemscollection.doc('9K6ue-afwwafwaf').valueChanges();
}
I think you are trying to do this:
constructor(db: AngularFirestore){
db.collection('yourcollection').doc("documentid").ref.get().then(function (doc) {
if (doc.exists) {
console.log(doc.data());
} else {
console.log("There is no document!");
}
}).catch(function (error) {
console.log("There was an error getting your document:", error);
});}
The above is the simplest way I know to read a document on firestore. It will show the internal data from your document. I hope it helps to you.
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