I need to return a value from this function and i have 2 parameters. I can not make escape function with completion. How to make it escape?
func myReturn(str:String,userCU:String)->String{
var res = ""
let refU = Database.database().reference(withPath: "users")
refU.child(userCU).observeSingleEvent(of:.value) {
(snapshot) in
if snapshot.exists(){
// print(snapshot)
let dict = snapshot.value as! [String:Any]
print(dict)
//dict["userCity"]
res = dict[str] as! String
print(res)
}
else {
print("noooooo")
}
}
print(res)
return res
}