I tried to get snapShot with React.js and Webpack, and had the error Uncaught (in promise) FirebaseError: Missing or insufficient permissions. Thank you very much in advance.
I suspected my webpack setting is something wrong to make the async request. However, when I tried the simple async request with the same setup, there is no issue. On top of this, Getting document also works correctly. I'm totally lost what I should do next.
//App.js
componentDidMount() {
this.unsubscribeFromAuth = auth.onAuthStateChanged(async user => {
this.setState({ user });
await createUserProfDoc(user);
});
}
//FireBase code
export const firestore = firebase.firestore();
export const createUserProfDoc = async (userAuth, additionalData) => {
if (!userAuth) {
return;
}
const userRef = firestore.doc('users/123');
const snapShot = await userRef.get();
console.log(snapShot);
};