title: FIREBASE: getting null while fetching the data from database
body: <blockquote>
    <p>Attached is the firebase db structure screenshot.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/fxD5O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fxD5O.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>I want to get the data using node script. below is my code.</p>
  </blockquote>
  
  <pre><code>var db = admin.database();
  var ref = db.ref("test/name");
  
  console.log(ref)
  
  ref.on("value", function(snapshot) {
      console.log("==========");
    console.log(snapshot.val());
  }, function (errorObject) {
    console.log("The read failed: " + errorObject.code);
  });
  </code></pre>
  
  <p><code>console.log(snapshot.val());</code> always print <strong>null</strong></p>
  
  <p>Below is the result of  <code>console.log(ref)</code></p>
  
  <pre><code>path: Path { pieces_: [ 'test', 'name' ], pieceNum_: 0 },
    queryParams_: QueryParams {
      limitSet_: false,
      startSet_: false,
      startNameSet_: false,
      endSet_: false,
      endNameSet_: false,
      limit_: 0,
      viewFrom_: '',
      indexStartValue_: null,
      indexStartName_: '',
      indexEndValue_: null,
      indexEndName_: '',
      index_: PriorityIndex {}
    },
  </code></pre>
  
  <p>What is the issue in the code?
  referring this document:  <a href="https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot" rel="nofollow noreferrer">https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot</a></p>