In firebase, I am working on the sign up function. I signup the user (using email and password).
firebase.auth().createUserWithEmailAndPassword(email,password1).catch(function(error) {
var errorCode = error.code;
var error = document.getElementById("hiddenmessage");
switch (errorCode) {
case 'auth/email-already-in-use':
error.innerHTML = "The account associated to "+email+" already exists. <a class=\"whitelink\"href=\"login.html\">Login here.</a>";
error.style = "display: block;";
break;
//For future error code development
default:
error.innerHTML = errorMessage + "ERROR: <br>"+error.message+"<br>Try again later.";
error.style = "display: block;";
}
});
All of this is within another function, called the signUp()
function. How do I return from both functions? I have already tried using break;
and setting a variable.