lundi 26 novembre 2018

firebase data retrieval returns complex object

i want to retrieval data from firebase and display on website i tried most of the method but dosen't work for me.

Here is my firebase

"transactions" : {
"8527z732x5e5RZnaWlYnvXLQv1Z2" : {
  "102" : {
    "trans_amount" : "20",
    "trans_date" : "23/11/2018"
  },
  "103" : {
    "trans_amount" : 240,
    "trans_date" : "23/12/2018"
  }
},
"WfEQmVDBXeXFqrmzNslIPhD0UqQ2" : {
  "102" : {
    "trans_amount" : "20",
    "trans_date" : "23/11/2018"
  }
}

}

here is my code for retrieval

ref.on("child_added", function(snapshot) {
PrintData.innerText = ""; // We got a new value, so clear the existing 
HTML
snapshot.forEach(function(childSnapshot)  {
var childData = childSnapshot.val();                                 
//showing single object value
console.log(childData);
PrintData.innerText += "trans_amount: " + childData.trans_amount + " 
trans_date: " + childData.trans_date + "  ";
});
});

here is my output 1




Aucun commentaire:

Enregistrer un commentaire