[Vuejs]-How do I loop through a snapshot in Firebase

3👍

To loop through the ulds try the following:

once("value", function(snapshot) {
 snapshot.forEach(function(childSnapshot){
   childSnapshot.forEach(function(uldSnapshot){
     uldSnapshot.forEach(function(nestedUldSnapshot){ 
       console.log(nestedUldSnapshot.val());

        });
      });

First, use the event value to retrieve the data, then use forEach() to retrieve the data under the random ids. Then use another forEach() to access the data inside the ulds object.

Leave a comment