Wednesday, 20 January 2021

firestore set operator do not add any document

I have created a promise chain to store user to firestore and authentication in an order. First time, i used add operator but i decided that i should store user according to their uid for that reason i changed my code and now nothing saved to firestore. What is wrong ?

 firebase
            .auth()
            .createUserWithEmailAndPassword(email, password)
            .then((data) => {
              firebase
                .firestore()
                .collection("Users")
                .doc(data.user.uid)
                .set({
                  name: name,
                  surname: surname,
                  email: email,
                  password: password,
                  nickname: nickname,
                  birthdate: birthdate,
                })
                .then(() => {
                  firebase
                    .auth()
                    .currentUser.sendEmailVerification()
                    .then(
                      firebase
                        .auth()
                        .signOut()
                        .then(
                          navigation.navigate("SignIn", {
                            message: "Please verify your email.",
                          })
                        )
                    );
                })
                .catch((e) => console.log(e));
            })
            .catch((err) => console.log(err));

Note: The authentication works correctly.

Note2: There is no error on console.

Note3: I also noticed that if i changed the order like first store firestore and then store to authentication code works fine. Why in that order nothing happened.



from firestore set operator do not add any document

No comments:

Post a Comment