I made a function that connects to firebase, goes to a specific path and then gives me the value. When I print(snapshot.value), it gives me the value I need. When I call the function, userProfile is empty. I need userProfile to return the snapshot String.
 func getUserData(uid: String) -> String{
   var _REF_USERNAME = FIRDatabase.database().reference().child("users").child(uid).child("profile").child("username")
     var userProfile = String()
    _REF_USERNAME.observe(.value, with: {(snapshot) in
        print("SNAP: \(snapshot.value)")
            userProfile = snapshot.value as! String
    })
    print(userProfile)
    return userProfile
}