【问题标题】:Permission Error on using firebase使用 firebase 的权限错误
【发布时间】:2018-08-23 22:08:02
【问题描述】:

上面是我在尝试将数据插入到 firebase db 时遇到的错误的快照。

constructor(props) {
   super(props);
   this.app = firebase.initializeApp(DB_CONFIG);
   this.database = this.app.database().ref().child('notes');
   this.state = {
     notes : [],
   }
}

componentWillMount() {
   const prevNotes = this.state.notes;

   this.database.on('child_added', snap => {
      prevNotes.push({
        id: snap.key,
        data: snap.val().data,
      })

   this.setState({ notes: prevNotes });
   })
}

addNote(e) {
  if(e.which === 13) {
    this.database.push().set({ data: e.target.value });
  }
}

上面是我在数据库中添加注释的反应代码,我正在制作一个待办事项列表,addNote() 将在按键 ENTER 时添加一个新注释。

请帮帮我,我是第一次使用 firebase,是否有任何代理问题可能导致此问题?

【问题讨论】:

    标签: reactjs firebase firebase-realtime-database firebase-security


    【解决方案1】:

    问题解决了,我只是为数据库中的读/写规则设置为true,firebase实际上有两种类型的dbs Cloud firestore和realtime database..我实际上为我设置的cloud db设置了true实时数据库也是如此。

    【讨论】: