Reputation: 119
And this is what I'm trying, but it doesn't work. Any ideas?
const nameRef = firebase.firestore()
.collection('NegociosDev')
.doc('Peluquerias')
.collection('Negocios')
.doc('PR01')
.collection('citas')
.doc('1xCDFWiDx3jUdKo8R3AG')
nameRef.onSnapshot(doc => {
this.setState({
name: doc.data().Negocio
})
console.log(name)
})
Upvotes: 1
Views: 787
Reputation: 317352
Your console.log
line refers to a variable name
that is not defined in the database callback function, at least not that we can see. First try logging like this to see everything in the document:
console.log(doc.data())
If doc.data() returns undefined, that means you fetched a document that doesn't exist, and you should double-check the names of the collections and documents you're using.
Upvotes: 3