I'm trying to get the firstname from this:
The user is logged in and I can access his uid, but I can't get the Document that belongs to that user, this is how I'm trying to do it:
private func getDocument() {
var userID = Auth.auth().currentUser?.uid
userID = String(userID!)
var currentUser = Auth.auth().currentUser
// Get sspecific document from current user
let docRef = db.collection("users").document("bnf2s3RURUSV2Oecng9t")
// Get data
docRef.getDocument { (document, error) in
if let document = document, document.exists {
let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
print("Document data: \(dataDescription)")
} else {
print("Document does not exist")
}
}
}
If you noticed, if I put manually "bnf2s3RURUSV2Oecng9t" it will access the data, but the point is to be able to know what ""bnf2s3RURUSV2Oecng9t" is so I can put it on that hard coded variable on top. My end goal is be able to get the first name of the current user :)