title: How do I return a snapshot.val() from Firebase to a variable?
body: <pre><code>var getListings = function () {
      listingsRef.once("value").then(function(snapshot) {
          console.log(snapshot.val());
      }, function (errorObject) {
          console.log("The read failed: " + errorObject.code);
      });
  };
  </code></pre>
  
  <p>I have the following method. <code>console.log(snapshot.val())</code> is working as expected. However, if I <code>return snapshot.val()</code> it returns undefined. I cannot seem to figure out how to do <code>var currentSnapshot = getListings()</code></p>