title: TypeError: Cannot read property 'parent' of undefined
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>url = "www.w3schools.com/html/html5_video.asp"
  
  VIDEO_LINKS = [];
  VIDEO_LIST = [];
  
  function fillVideo(callback) {
    request(url, function(err, res, body) {
      if (body) {
        $ = cheerio.load(body);
      }
      links = $('source');
      $(links).each(function(i, link) {
        var value = $(link).attr('src');
        if (value.slice(-3) == "mp4" ||
          value.slice(-4) == "webm" ||
          value.slice(-3) == "ogv") {
          VIDEO_LINKS.push(value);
          VIDEO_LIST.push($(link).text());
  
        }
  
      })
      callback();
    });
  }
  
  function writeVideo() {
  
    for (j = 0; j &lt; VIDEO_LIST.length; j++) {
      request(VIDEO_LINKS[j]).pipe(fs.createWriteStream(VIDEO_LIST[j]));
    }
  }
  
  fillVideo(writeVideo);</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//www.electronicinfo.ca/printable-pdfs
  
  PDF_LINKS = [];
  PDF_LIST = [];
  
  function fillPDF(callback) {
    request(url, function(err, res, body) {
      $ = cheerio.load(body);
      links = $('a');
      $(links).each(function(i, link) {
        var value = $(link).attr('href');
        if (value.slice(-3) == "pdf") {
          PDF_LINKS.push(value);
          PDF_LIST.push($(link).text());
        }
      })
      callback();
    });
  }
  
  function writePDF() {
    for (j = 0; j &lt; PDF_LIST.length; j++) {
      request(PDF_LINKS[j]).pipe(fs.createWriteStream(PDF_LIST[j]));
    }
  }
  
  fillPDF(writePDF);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Hi, This is code that used to work, I changed literally nothing, from about 5 minutes ago, the only thing I changed was duplicating it, and changing variable names. My question is how to fix this code? I know the error is that body is empty, but I dont know how to fix it, i would appeciate any help...</p>