title: can't access firebase database snapshot values outside promises
body: <p>I can't access snapshot value outside promises. I have these functions</p>
  
  <pre><code>function getAuthorData() {
    metadataRef
      .child("author")
      .on("value", (snap) =&gt; {
        return snap.val()
      })
  }
  
  function getSiteSocialLinks() {
    metadataRef
      .child("social")
      .on('value', (snap) =&gt; {
        return snap.val();
      })
  }
  
  function getFeaturedPosts() {
    featuredRef.on('value', (snap) =&gt; {
      return snap.val();
    })
  }
  
  function getBlogPosts() {
    blogPostsRef
    .orderByChild('createOn')
    .on('value', (snap) =&gt; {
      return snap.val()
    });
  }
  
  function getPostCategories() {
    postRef
    .child('categoryStats')
    .on('value', (snap) =&gt; {
      return snap.val();
    });
  }
  
  function getTotalPostsLength() {
    postRef
    .child('nopp')
    .on('value', (snap) =&gt; {
      return snap.val();
    })
  }
  </code></pre>
  
  <p>and when I try this </p>
  
  <pre><code>var ourPosts = getBlogPosts()
    var ourCategories = getPostCategories()
    var totalnumOfPosts = getTotalPostsLength()
  
    console.log(`Our post: ${ourPosts}\n our categories: ${ourCategories}\n total number of posts: ${totalnumOfPosts}\n`)
  </code></pre>
  
  <p>this is what I get </p>
  
  <blockquote>
    <p>Our post: undefined  our categories: undefined  total number of posts:
    undefined</p>
  </blockquote>
  
  <p>I dont really know if it has anything to do with scope. Please help</p>