/// ** Figured out my problem ** ///
It’s a fairly simple function. While the authentication catches the error, my program immediately exits the “createUser…” function and the error prints after the exit. As a result, I can’t display the error to the user.
I’ve tried it without the “then” statement, as it’s written in Google’s API. I’ve also tried adding a manual setTimeout function to delay the console.log function. Nothing works.
How can I make that catch statement “wait” long enough so that I can display an error message?
register(user: User){
firebase.auth().createUserWithEmailAndPassword(user.email, user.password).then(function(userCredential) {
console.log(userCredential.user);
}).catch(function(error){
var errorCode = error.code;
var errorMessage = error.message;
console.log('Firebase register error caught: '+errorMessage);
// ADDED SetTimeout function //
// setTimeout(console.log('Firebase register error caught: '+errorMessage), 20000);
});
console.log('Bounced out of create function');
}