title: How can I return the fetch API results from a function?
body: <p>I want to return fetch API result from a function. but I get undefined and that function doesn't return me fetched data :</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>function func() {
      fetch('https://randomuser.me/api/?results=10')
      .then(response =&gt; response.json())
      .then(json =&gt; (json.results))
  }
  
  let users = func()
  
  console.log(users);</code></pre>
  </div>
  </div>
  </p>