firebase get array of data code example
Example 1: firebase snapshot to array
function snapshotToArray(snapshot) {
var returnArr = [];
snapshot.forEach(function(childSnapshot) {
var item = childSnapshot.val();
item.key = childSnapshot.key;
returnArr.push(item);
});
return returnArr;
};
Example 2: firebase snapshot to array
firebase.database().ref('/posts').on('value', function(snapshot) {
console.log(snapshot.val());
});