title: Insert var into url and follow in node js with cheerio/request
body: <p>I am trying to take a variable from the original url, insert it into a second url, visit that url and then access variable from it. I have two problems: </p>
  
  <p>Problem 1: 'myurl' variable returns value of </p>
  
  <pre><code>"http://api.trove.nla.gov.au/work/undefined?key=6k6oagt6ott4ohno&amp;reclevel=full"
  </code></pre>
  
  <p>That is, it is not taking the 'myid' variable.</p>
  
  <p>Problem 2: How do I then follow the 'myurl' url as I want to access the DOM? Do I make another 'request' for 'myurl'?</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>var request = require('request'),
      cheerio = require('cheerio');
  request('http://api.trove.nla.gov.au/result?key=6k6oagt6ott4ohno&amp;zone=book&amp;l-advformat=Thesis&amp;sortby=dateDesc&amp;q=+date%3A[2000+TO+2014]&amp;l-availability=y&amp;l-australian=y&amp;n=0&amp;s=0', function(error, response, html) {
      if (!error &amp;&amp; response.statusCode == 200) {
          var $ = cheerio.load(html, {
            xmlMode: true
          });
  
          var myid = ($('work').attr('id'))
          var myurl = "http://api.trove.nla.gov.au/work/" +(myid)+ "?key=6k6oagt6ott4ohno&amp;reclevel=full"
          console.log(myurl)
      }
      });
  </code></pre>