I am trying to create a registration system with jquery and firebase, and the problem I am having problems with does not know what 'call to firebase' returns. Let me show you in my code:
HTML (simplified by removing irrelevant code):
<div id="registerForm">
<input type="text" id="userEmail" placeholder="Email">
<input type="password" id="userPass" placeholder="Password">
<button type="button" id="register">Register</button>
</div>
JQuery (again, only showing code related to Firebase and registration):
<script src=" /* Jquery url */ "></script>
<script src=" /* Firebase url */ "></script>
<script>
var config = {
apiKey: "*my api key*",
authDomain: "*myProject*.firebaseapp.com",
databaseURL: "https://*myProject*.firebaseio.com",
storageBucket: "*myProject*.appspot.com",
};
firebase.initializeApp(config);
</script>
<script>
$('#register').click(function() {
var email = $('#userEmail');
var pass = $('#userPass');
if(email.val() && pass.val()){
firebase.auth().createUserWithEmailAndPassword(email.val(), pass.val()).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode + ' - ' + errorMessage);
});
console.log('this message shouldn\'t show if there wasn\'t an error.');
if(error) {
console.log('there was an error');
} else {
console.log('everything went fine');
}
} else {
console.log('fill in both fields');
}
});
</script>
if-else, , firebase.auth. , , , dDdails dddails .., , , , firebase.auth. , , , firebase, - if (firebase.auth.success( - )) {} else {}.
, , , firebase, , . , , / firebase , , , firebase.
, /, , SO, .
, !