I am learning node js and i am learning firestore right now. I am using the firestore emulator. I am making a todo app. Whenever i try and get a doc from firestore it says it doesn’t exist.When i console log the doc it return a promise that is pending here is my code to read the data:
var docRef = db.collection(‘todos’);
console.log(docRef);
var doc = docRef.doc(‘todo1’);
const docinfo = docRef.get();
if (!doc.exists) {
console.log(‘No such document!’);
} else {
console.log(‘Document data:’, docinfo.data());
}
All the code is based of the firebase documentation
(https://firebase.google.com/docs/firestore/query-data/get-data#node.js_2).
The json it should return is:
{
item: “test”
}
Can anyone help me?