title: Chain multiple Node http request
body: <p>I am new to node and need to call a 3rd party api from my code. I found how to do this by using http.request from this link <a href="https://docs.nodejitsu.com/articles/HTTP/clients/how-to-create-a-HTTP-request" rel="noreferrer">https://docs.nodejitsu.com/articles/HTTP/clients/how-to-create-a-HTTP-request</a>. What I need to do is call two different api urls and use the response data from the first call in the second call which will just be an id as a param on resource2. </p>
  
  <p>I do not know how I would chain two of these calls together without it being a duplicated mess. Any help would be appreciated.</p>
  
  <pre><code>var url1 = {
      host: 'www.domain.com',
      path: '/api/resourse1'
  };
  
  var url2 = {
      host: 'www.domain.com',
      path: '/api/resourse2/{id}'
  };
  
  var callback = function (response) {
      var str = '';
  
      response.on('data', function (chunk) {
          str += chunk;
      });
  
      response.on('end', function () {
          console.log(str);
      });
  }
  
  http.request(url1, callback).end();
  </code></pre>