Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Created June 5, 2021 09:53
Show Gist options
  • Save jhonsore/b560c3c282ae45ad1770f039851c7d56 to your computer and use it in GitHub Desktop.
Save jhonsore/b560c3c282ae45ad1770f039851c7d56 to your computer and use it in GitHub Desktop.
Firebase tips
// Auth an user and create it instantly in users collection
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
return firebase.firestore().collection('users').doc(userCredential.user.uid)
.set({
field1: 'my-field-value',
field2: 'my-field-value'
);
})
.then(() => {
// user created
})
.catch((error) => {
var errorCode = error.code;
var errorMessage = error.message;
// ..
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment