尝试将我的react应用程序与Firebase连接以获取错误。
Uncaught (in promise) Error: permission_denied at /tests: Client doesn't have permission to access the desired data.
我已经阅读了所有的答案,一切似乎都是正确的任何人请看看哪里出错了。
当我在模拟器中使用模拟器type = get
模拟器位置= database/tests
测试规则时,它向我显示成功输出。
我可能没有正确使用ref
里面的React app - 我正在使用的包 - "firebase": "^5.4.2",
反应代码 1.Config.js文件
// Initialize Firebase
import firebase from 'firebase';
const config = {
apiKey: "xxxx",
authDomain: "xxxx",
databaseURL: "xxxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId: "xxx"
};
const fire = firebase.initializeApp(config)
export { fire }
2.在我的容器组件中
import { fire } from '../../Config/Config';
componentWillMount() {
let testRef = fire.database().ref().child('tests');
//also tried this
//let testRef = fire.database().ref('tests');
console.log('testRef', testRef)
testRef.once("value").then((f) => {
console.log(f);
});
}
3.我的firebase帐户中的规则
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}