title: How to retrieve data from Firebase using Javascript?
body: <p><a href="https://i.stack.imgur.com/6F1QC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6F1QC.jpg" alt="enter image description here"></a></p>
  
  <p>I'm trying to access "id" and store it in a variable. So far the code I have is:</p>
  
  <pre><code>var ref = firebase.database().ref("users");
  
  ref.on("value", function(snapshot) {
    snapshot.forEach(function(childSnapshot) {
      var childData = childSnapshot.val();
      console.log(childData);
    });
  });
  </code></pre>
  
  <p>What I get from above is:</p>
  
  <p><a href="https://i.stack.imgur.com/xANnb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xANnb.jpg" alt="enter image description here"></a></p>
  
  <p>With that I have access to the object itself, but how can I access the property "id"? I'm reading the <a href="https://firebase.google.com/docs/database/admin/retrieve-data" rel="nofollow noreferrer">official documentation</a> but I can't figure it out.</p>