i'm trying to get the firebase fetchProvidersForEmail to set a boolean outside of the completion closure but I am not sure how since the request is asynchronous. This is what I have:
FIRAuth.auth()?.fetchProvidersForEmail(emailSignUpTextField.text!, completion:{(providers, error) in
if error != nil{
print(error)
if error!.code == FIRAuthErrorCode.ErrorCodeInvalidEmail.rawValue{
self.showErrorAlert("Invalid Email", msg: "Please input a valid email.")
}
}
else{
//If there are no errors and there are providers, the email exists
if providers != nil{
self.showErrorAlert("Email in Use", msg: "There is already an account created with that email.")
}
//The email does not exist
else{
self.segueBool = true
print("it works")
}
}
})
self.segueBool is what I need to set to true if there are no errors. Any help would be appreciated.