var config = {
apiKey: "A**********************kBs",
authDomain: "the**********.firebaseapp.com",
databaseURL: "https://***********.firebaseio.com",
projectId: "the-o***********nette",
storageBucket: "the***********.appspot.com",
messagingSenderId: "6***********6"
};
firebase.initializeApp(config);
$("#register").click(
function(){
var email=$("#regEmail").val();
var password=$("#regPass").val();
var fname=$("#regfName").val();
var lname=$("#reglName").val();
firebase.auth().createUserWithEmailAndPassword(email,
password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert(errorMessage)
// ...
});
alert( "you have successfully registered");
// Get a reference to the database service
var database = firebase.database();
var userId = firebase.auth().currentUser;
firebase.database().ref('users/' + userId).set({
fname: fname,
lname: lname,
email: email,
}).catch(function(error){
var errormsg=error.message;
console.log(errormsg);
});
}
);
The createuserwithemailandpassword is working properly. But I am not able to add anything into the database. No error log is reported. The var is mentioned in the HTML file. Let me know if anything else is needed. thanks!
Aucun commentaire:
Enregistrer un commentaire