【问题标题】:Firebase returning array with null and some object in JavascriptFirebase在Javascript中返回带有null和一些对象的数组
【发布时间】:2017-01-16 21:17:08
【问题描述】:

// Initialize Firebase
var config = {
  apiKey: "AIzaSyAGHEgm48s7_QkBwLw0UX-yCBLQg06zvdA",
  authDomain: "fir-bef76.firebaseapp.com",
  databaseURL: "https://fir-bef76.firebaseio.com",
  storageBucket: "fir-bef76.appspot.com",
  messagingSenderId: "207871344593"
};
firebase.initializeApp(config);
var ref = firebase.database().ref("employeeAttendace")
  .child("427188EI/2017/1");

ref.once("value").then(function(data) {
  console.log(data.val());
});
<script src="https://www.gstatic.com/firebasejs/3.6.5/firebase.js"></script>

<!DOCTYPE html>
<html>

<head>

</head>

<body>

</body>

</html>

我将我的数据存储在 firebase 中。但是在获取数据时,我得到的数组填充了 null,并且对象而不是 JSON 对象。


   JSON Structure:
    employeeAttendance
      -4114EI
        -2017
          -1
             -1:{Key:value}
             -2:{Key:Value}
             -3:{Key:Value}
             -4:{Key:Value}
             -5:{Key:Value}

firebase 获取代码:

    var ref=firebase.database().ref("employeeAttendance/4114EI/2017/1");
ref.once("value",function(data){


  //Here i am getting 
[null,null,{key,value},{key,value},{key,value}]
        });

请帮我解决空值问题

Expected Output

Output Getting

【问题讨论】:

    标签: javascript node.js firebase firebase-realtime-database


    【解决方案1】:

    我得到了解决方案。实际上 JSON 结构的格式不符合 firebase 规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-17
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 2021-03-25
      相关资源
      最近更新 更多