Reputation: 31
I’m trying to make a website where a user can login with a username a password and a name
This function is not implemented in firebase authentication option so I tried using its real-time database Here is my code so far:
export function signup(email, password, name) {
return auth().createUserWithEmailAndPassword(email, password).then((userCredential) => {
db.ref("users").ref(userCredential.uid).push({
name: name
});
})
}
Saving the data does not work but I think I have a good start.
Upvotes: 0
Views: 134
Reputation: 1952
Try passing only one ref()
call and set()
instead of push()
:
export function signup(email, password, name) {
return auth().createUserWithEmailAndPassword(email, password).then((userCredential) => {
db.ref("users/" + userCredential.user.uid).set({
name: name
});
})
}
Upvotes: 2