Currently in the process of retrieving items from my Firebase database, I am utilizing a snapshot that is generated when the page loads. I have collected the values of each object in an array and I am now attempting to add an item from each object into a separate array using a for loop.
However, upon creation of the second array, I am encountering an issue where there are more items present than there are objects within the snapshot.
I am seeking guidance on how to address this issue. Any assistance would be greatly appreciated. Thank you.
Here is the code snippet:
var ref = firebase.database().ref().child('/scenes/' + projId).orderByChild('wordcount');
ref.once('value',function(snap) {
snap.forEach(function(item) {
var itemVal = item.val();
keys.push(itemVal);
for (i=0; i < keys.length; i++) {
counts.push(keys[i].wordcount);
}
});
});