Firebase Firestore Query get One result
Your query returns a QuerySnapshot
(see docs). You can access the docs as an array via the docs
property; each doc has a data()
method:
export const findUserByEmail = email => {
return firestore()
.collection('users')
.where('email', '==', email.toLowerCase())
.get()
.then(querySnapshot => {
if(!querySnapshot.empty) {
const user = querySnapshot.docs[0].data()
// rest of your code
}
})
}