Sample firebase code, not working
Hello, I tried the sample code (from here : https://firebase.google.com/docs/firestore/query-data/get-data)
var docRef = db.collection("cities").doc("SF");
docRef.get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
// doc.data() will be undefined in this case
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
Their base code, I get an error.
Here is my adaptation (also has error):
var docRef = this.firestore.collection('Clients').doc(clientId);
docRef.get().then( doc =>
{
let test = doc.data() as ClientModel
clientName = test.ClientName;
console.log(test);
});
The 'then following from docRef.get()' produces this error:
Property 'then' does not exist on type 'Observable<DocumentSnapshot>'.ts(2339)
From my research, it appears with angular I am using an observable, however, when I tried to convert to a promise it just froze.
Any ideas what I am doing wrong?