title: Returning a value in a function of a function
body: <p>The following snippet returns <code>undefined</code> instead of an expected array of links. apiCall() is from <a href="https://www.npmjs.com/package/request" rel="nofollow noreferrer">here</a>. </p>
  
  <p>Is it possible to return the array? If so how? If not why?</p>
  
  <pre><code>async function fetchData() {
  
     await apiCall('https://www.googleapis.com/youtube/v3/search?q=leeroyjenkins&amp;maxResults=4&amp;part=snippet&amp;key={KEY}', 
         (error, response, body) =&gt; {
        return JSON.parse(body).items.map(i =&gt; 'https://www.youtube.com/watch?v=' + i.id.videoId)
  
              })
  
  }
    fetchData().then(r =&gt; console.log(r))
  </code></pre>
  
  <p>EDIT: The following code seems to work; </p>
  
  <pre><code>async function fetchData(param, fn) {
  
     await apiCall('https://www.googleapis.com/youtube/v3/search?q=leeroyjenkins&amp;maxResults=4&amp;part=snippet&amp;key={KEY}', 
         (error, response, body) =&gt; {
        fn(JSON.parse(body).items.map(i =&gt; 'https://www.youtube.com/watch?v=' + i.id.videoId))
  
              })
  
  }
  fetchData('lee', function(Ar) { console.log(Ar) })
  
  };
  </code></pre>
  
  <p>Can someone point out why?</p>