I have an function inside my app witch returns an image url from my firebase real-time database, but for some reason the value of url
variable never change and returns the default value witch is none
My function:
func getImageURL() -> String {
let ref: DatabaseReference = Database.database().reference()
var url: String = "none"
ref.child("users").child(Auth.auth().currentUser?.uid ?? "noid").observeSingleEvent(of: .value) { snapshot in
url = snapshot.childSnapshot(forPath: "photoUrl").value as! String
} withCancel: { error in
print("ERROR: \(error.localizedDescription)")
}
return url
}