title: Http get multiple json files from different API endpoints using node express
body: <p>I'm looking into the most efficient way to get multiple JSON files from different API endpoints using node.</p>
  
  <p>Basically i'd like to store each JSON object in a variable, and send them all to Jade template files for parsing.
  I've got it setup working for getting <strong>one single</strong> JSON file (jsonFile1) by doing the following:</p>
  
  <pre><code>httpOptions = {
      host: 'api.test123.com',
      path : '/content/food/?api_key=1231241412',
      headers: {
          "Accept": "application/json",
          'Content-Type': 'application/json'
      },
      method: "GET",
      port: 80
  }
  
  var jsonFile1;
  
  http.get(httpOptions, function(res) {
      var body = '';
  
      res.on('data', function(chunk) {
          body += chunk;
      });
  
      res.on('end', function() {
          jsonFile1= JSON.parse(body)
          console.log("Got response: " + jsonFile1);
      });
  }).on('error', function(e) {
      console.log("Got error: " + e.message);
  });
  
  app.set('views', __dirname);
  
  app.get('/', function(req, res) {
      res.render('home', {
          data: jsonFile1
      });
  });
  </code></pre>
  
  <p>But i don't really want to have to repeat all of this to get <strong>multiple</strong> json endpoints and send them to home jade template. </p>
  
  <p>Any ideas to do this efficiently?</p>