DEV Community

Mayank
Mayank

Posted on

Answer: Function creates new user authentication in firebase but won't create a corresponding document in User collection

Make sure you have already created the collection named "users".

Edit your code as follows to log cred and/or errors so that you can effectively debug the issue.

function signup(email, password) {
  return auth.createUserWithEmailAndPassword(email, password)
  .then(cred => {
    console.log(cred)
    return firebase.firestore().collection('users').doc(cred.user.uid)
           .set({email})
    })
}
// as you are returning

Top comments (0)