I am creating an app that allows users to register themselves.
Using react-native and firebase works, the are registered and are logged in. Even the additional data is stored in the realtime database (I checked it). But I am getting a message saying "creating user failed" (it is one of the messages I have setup).
This is the code I use to create users and add additional data to the realtime database:
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((user) => {
firebase.database().ref('users/' + user.uid).set({
firstName: firstName,
lastName: lastName,
email: email,
code: code
})
})
.then(user => loginUserSuccess(dispatch, user))
.catch((error) => {
createUserFail(dispatch)
console.log(error);
});
I also checked the debugger in android studio (don't know about ios yet) and saw the following comment:
TypeError: undefined is not an object (evaluating 'user.uid')
Still everything is saved, but the error message was shown. What am I doing wrong?
user.uid, can you console.log that and also console.log thefirebase.database().ref('users/' + user.uid)and see what you get.