【发布时间】:2020-01-17 21:56:39
【问题描述】:
我尝试使用 React.js 和 Webpack 获取 snapShot,但出现错误 Uncaught (in promise) FirebaseError: Missing or enough permissions。 非常感谢您。
我怀疑我的 webpack 设置有问题,无法发出异步请求。但是,当我尝试使用相同设置的简单异步请求时,没有问题。最重要的是,获取文档也可以正常工作。我完全不知道下一步该做什么。
//App.js
componentDidMount() {
this.unsubscribeFromAuth = auth.onAuthStateChanged(async user => {
this.setState({ user });
await createUserProfDoc(user);
});
}
//FireBase代码
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);
};
【问题讨论】:
标签: reactjs firebase google-cloud-firestore firebase-security