title: How do I return a string from my async function using the request API?
body: <p>What I am trying to do is print the HTML code source as a sting using the request API, I've declared a function that fetches the data as a string put when I print the output, it returns undefined. I can't figure out what I'm doing wrong.</p>
  
  <p>file1.js</p>
  
  <pre><code>const request = require('request');
  
  var test = getMovieTitles();
  var output;
  
  test.then(function(result) {
      output = result;
  })
  
  //prints undefined
  console.log(output);
  
  
  async function getMovieTitles(){
      return new Promise(function(resolve, reject) {
      request('https://www.google.com',function nes(err, res, body) {  
          resolve(body);
          });
      })
  }
  
  module.export = test
  </code></pre>
  
  <p>file2.js</p>
  
  <pre><code>var sourceFile = require('./run.js');
  
  sourceFile.test.then(function(result) {
      console.log(result);
  })
  </code></pre>