I am new to javaScript. I am retrieving 10 values of pulse rate data from the firebase. The data was successfully retrieved but the problem is only the recent value .i.e last value is showing on the HTML page. I want to show all 10 values on the HTML page. Here's the code :
test.html
<body>
<div >
<p id="hearbeat_prev"></p>
</div>
</body>
test.js
(function () {
console.log("inside unkonwn");
heartbeat_previous_data();
})();
function heartbeat_previous_data()
{
var rootRef = firebase.database().ref("pulse");
var numbers = new Array();
rootRef.limitToLast(10).on('child_added', function(snap) {
var heart = snap.child("rate").val();
console.log(heart);
document.getElementById("hearbeat_prev").innerHTML =heart;
});
}
ScreenShot: Check the image for the output and for console data