samedi 26 septembre 2020

How to create a document with user 'uid' in Firebase firestore

I am trying to create a document with an id that of the user as he signs up

this is the function which runs when user signs up ->

const register = (e) => {
    e.preventDefault();

    auth
      .createUserWithEmailAndPassword(email, password)
      .then((auth) => {
        if (auth) {
          db.collection("users").add({
            email: email,
            password: password,
          });

          history.push("/");
        }
      })
      .catch((error) => alert(error.message));
  };

Can anyone help me with how do I pass the .doc reference to accomplish this?




Aucun commentaire:

Enregistrer un commentaire