Document not being found in node js firebase

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
(Get data with Cloud Firestore  |  Firebase).
The json it should return is:
{
item: “test”
}
Can anyone help me?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.