Firebase v3 Reference Guide indicates that createUserWithEmailAndPassword(email, password)
returns firebase.Promise
containing non-null firebase.User
.
The Firebase v3 Authenticate with Firebase using Password-Based Accounts Guide shows the following example
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
My question is, I want to fire a function which adds the user to my users
node in my Realtime Database. I want to include the users display name that I collected from the sites registration form. So, it seems like I want to do a .then
and if the createUserWithEmailAndPassword
method was successful I want to fire a function that writes the new user (with display name) to my Realtime Database users
node.
How do I modify the example script to a .then
style?