Given the following data in our db:
And let us say I have the following code:
function person() { db.collection('groups').get().then(function (querySnapshot) { querySnapshot.docs.forEach(function (doc) { console.log(doc.data().users[0].val()) }); }); }
How do I display to console that email1@.com ?
When I call console.log(doc.data().users) I get this
console.log(doc.data().users)
Try without val(), the place of val() in doc.data().users[0].val() should be another field of element of the array:
val()
doc.data().users[0].val()
doc.data().users[0]