title: Returning query data from a function to a jade/express.js page
body: <p>I've been trying several different methods to try and take an array containing data from a SQL query using express.js an display it on a page using express and Jade templates. I've convoluted the process somehow by reading too many different methods of doing so, but I'm just not grasping the fundamental concept.</p>
  
  <p>Essentially I have app.js with a function called fetchData that creates a connection to a DB2 database and stores the rows in an array. I'm able to see that printing out to the console log successfully. My problem lies in returning that array to the web page generated by express and Jade. I've used the tutorial and created the basic page using: </p>
  
  <pre><code>router.get('/', function(req, res, next) {
      res.render('index', { title: 'Express'});
  });
  </code></pre>
  
  <p>After that I've tried:</p>
  
  <pre><code>module.exports = router;
  
  exports.init = fn1.fetchData();
  
  exports.list = function (req ,res) {
    res.render('iData', { 'iData': dData });
  }
  </code></pre>
  
  <p>But this for sure does not seem right and is not working when I attempt to display it using the jade template:</p>
  
  <pre><code>extends layout
  
  block content
    h1= title
    p Howdy, welcome to #{title}
    ul
      for val in iData
        li= val
  </code></pre>
  
  <p>Does anyone know of a good guide or method to do what I'm trying to do? It seems fairly basic, I'm just not using the ingredients (node, express, jade) correctly.</p>