I am new to swift and I am trying to get the data from the firebase cloudbase database and trying to assign them in dictionary.
I have tried putting them on a dictionary and printing the values but it doesnot show anyerror message or print anything on the console.
func fetchUser(){
let db = Firestore.firestore()
db.collection("users").getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
if let dict = document as? Dictionary<String, Any> {
let email = dict["email"] as! String
print(email)
}
}
}
}
}
I want to print all the email from the users collection and display on the console.
I hope this will help you