title: How to make multiple API calls using request in NodeJs?
body: <p>Creating a simple <code>Node.Js</code> app where need to display data from two APIs, where both APIs returns multiple objects with an ID. </p>
  
  <p>Need to display data from both these APIs on a single page, and somehow need to fetch the data from the two API based on the ID.</p>
  
  <p>API 1 response looks like this:</p>
  
  <pre><code>    {
      "hikes": [
          {
              "id": 1,
              "active": true,
              "name": "Mt. Everest",          
          },
          {
              "id": 2,
              "active": true,
              "name": "K2",          
          },
          {
              "id": 3,
              "active": true,
              "name": "Mt. Kinley",          
          },
      ]
  }
  </code></pre>
  
  <p>API 2 response looks like this:</p>
  
  <pre><code>{
      "hikes": [
          {
              "id": 1,
              "slots": 50,
              "available": 23,          
          },
          {
              "id": 2,
              "slots": 20,
              "available": 1,          
          },
          {
              "id": 3,
              "slots": 43,
              "available": 20,          
          },
      ]
  }
  </code></pre>
  
  <p>Need to pull both APIs, fetch the data and render on a page to display "name", "slots", and "available".</p>
  
  <p>This far managed to pull one of the APIs, and pass the data to a rendered <code>index.ejs</code> page, but I am not sure how I should pull the second API and some how fetch the data`s.</p>
  
  <p>My code at the moment looks like this:</p>
  
  <pre><code>var port    = process.env.PORT || 3000,
      express = require("express"),
      request = require("request"),
      app = express();
  
  app.set("view engine", "ejs");
  
  
  
  
  
  var hikes = {
      url: "https://api.com/hikes",
      headers: {
        'Identifier': identifier
      }
    };
  
    var availability = {
      url: "https://api.com/hikes",
      headers: {
        'Identifier': identifier
      }
    };
  
  
  app.get("/", function(req, res){
  
  
        function callback(error, response, body){
            if(!error &amp;&amp; response.statusCode == 200){
                var data = JSON.parse(body);
                res.render("index", {data: data});
                })
            }
        }
      request(hikes, callback);
  });
  
  
  app.listen(port, function(){
      console.log("Running");
  });
  </code></pre>
  
  <p>In my index.ejs, I for now have created a simple loop to print the names:</p>
  
  <pre><code>&lt;% data["hikes"].forEach(function(hike){ %&gt;
  
      &lt;p&gt;&lt;%= hike.name %&gt;&lt;/p&gt;
  
  &lt;% }) %&gt;
  </code></pre>
  
  <p>Any ideas on how to solve this? </p>
  
  <p>Thanks!</p>