Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase setDoc() not creating document

I'm creating a new user with auth which is working then taking that newly create uid to create a new document with the same.

const currentUser = await auth.createUserWithEmailAndPassword(email, pass);
        console.log('user registered')
        await setDoc(doc(db, "users", currentUser.user.uid),{
            forname: "Peter",
            surname: "Parker"
        })
        console.log('user profile added')
    dispatch({type:'USER_REG', payload: currentUser});

The reg process fires off without issue as I get the console log then the program just waits, its like setDoc is running but never completing and I have no idea why. Any help is appreciated.

like image 550
SlugLord Avatar asked Aug 13 '26 08:08

SlugLord


1 Answers

I faced a similar issue with firebase firestore's setDoc() function for me the problem was actually due to firestore rules being set too restrictively and not allowing to setdocs.

check the rules and adjust them:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}
like image 71
nowa Avatar answered Aug 15 '26 22:08

nowa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!