{"-L0bFExUeZXB3-MUXCda":{"Comment":"GOOD","Date":"18 December","User":"OlaNord"}}
{"-L0bFCJh5SPUOWMjTRKu":{"Comment":"ok","Date":"18 December","User":"OlaNord"}}
{"-L0bFA2uzsGDizxxzN1p":{"Comment":"wewwe","Date":"18 December","User":"OlaNord"}}
Within this array containing objects, there are various values that I need to access. However, when attempting to retrieve the key name, it returns undefined.
Below is the code snippet:
// Path for selected category
var categoryRef = firebase.database().ref("forum/" + currentCategory);
categoryRef.once("value", function(snapshot) {
firebase.auth().onAuthStateChanged(user => {
var userKey = user.uid;
var commentsArr = [];
for (var commentKey in snapshot.val()) {
var postComments = snapshot.val()[commentKey]['comments'];
commentsArr.push(postComments);
}
})
})