Firebase未与React Application连接 - 权限被拒绝 - 在线检查所有问题没有解决方案

问题描述 投票:1回答:1

尝试将我的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;
        }
      }
    }
  1. 测试节点中的数据

Image representing how node is present in my databse

javascript reactjs firebase react-native
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.