【问题标题】:React-native : Firebase how to get all the data [closed]React-native:Firebase 如何获取所有数据 [关闭]
【发布时间】:2017-10-02 19:09:40
【问题描述】:

大家好,我怎样才能从这种数据库结构中请求所有数据?

我试过了,但它不起作用:

 var recentPostsRef = firebase.database().ref('/store');

【问题讨论】:

    标签: firebase react-native firebase-realtime-database


    【解决方案1】:

    您在正确的轨道上,但缺少.then() 与回调一起使用的检索部分:

    var recentPostsRef = firebase.database().ref('/store');
    recentPostsRef.once('value').then(snapshot => {
      // snapshot.val() is the dictionary with all your keys/values from the '/store' path
      this.setState({ stores: snapshot.val() })
    })
    

    firebase.database.Reference 文档中有很多很好的示例和解释可以提供帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多