title: Fetch random user API
body: <p>I'm trying to use the random user API to fetch some data, but seeing a &quot;Failed to fetch&quot; error. Could someone point me in the right direction for how to fix this? TIA :)</p>
  <pre><code>async function getUsers() {
    let users = await fetch('https://randomuser.me/api/?results=2');
    let data = await users.json();
  }
  
  await getUsers();
  </code></pre>
  <p>Errors:</p>
  <pre><code>GET https://randomuser.me/api/?results=5 net::ERR_FAILED
  Uncaught (in promise) TypeError: Failed to fetch
  </code></pre>
  <p>Promise:</p>
  <pre><code>Promise {&lt;pending&gt;}__proto__: Promise
  [[PromiseState]]: &quot;rejected&quot;
  [[PromiseResult]]: TypeError: Failed to fetch
  </code></pre>
  <p><a href="https://i.stack.imgur.com/yQP0d.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yQP0d.jpg" alt="async-await-fetch-fail1" /></a></p>
  <p><em>UPDATE: it turns out I was testing this in a new tab/blank page, which does not show the full error which was:
  &quot;Access to fetch at '...' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.&quot;
  I installed a Chrome extension to resolve this for now, although I'm sure there's probably a better/more permanent way to fix this, and I might try that some other day!</em></p>