title: Retrieve from firebase and render in ejs
body: <p>So I'm basically trying to do a "foreach" loop for my ejs frontend but I can't seem to res.render the snapshot in the server.js. I can't seem to get the variable into the res.render(). I have no problem retrieving the data from firebase FYI.</p>
  
  <p>I've already tried various methods such as moving it in the ref.on etc</p>
  
  <pre class="lang-js prettyprint-override"><code>app.get('/', function (req, res) {
      var ref = database.ref('Courses');
      // var ref = firebase.database().ref("users");
      ref.on("value", function (snapshot) {
          snapshot.forEach(function (childSnapshot) {
              var childData = childSnapshot.val();
          });
      });
      res.render('pages/index', {
          ChildData: childData
      });
  });
  </code></pre>