title: Firebase wait for response
body: <p>If i have something like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const query = firebase.database().ref("/posts").orderByChild('postid').equalTo(1);
  query.once('value', snapshot=&gt;{
    if(snapshot.val() == "XYZ"){
      console.log("true");
      return true;
    }
  });
  console.log("false");
  return false</code></pre>
  </div>
  </div>
  </p>
  
  <p>why is is this printing<br>false<br>true<br></p>
  
  <p>how can i force to wait for the answer of query before jumping to the return false?</p>