title: How do you make an API request using browser fetch with token auth
body: <p>I'm trying to make an API request using fetch(browser). A token is required in the headers to make the request.</p>
  
  <p>I can make successful requests in node (server side).
  However, when making requests on the browser, the <code>OPTIONS</code> request fails with 401.</p>
  
  <pre><code>const order_url = new URL(process.env.API_URL + 'orders/');
  const params = { type: 'amazon', status: 'in_queue' };
  Object.keys(params).forEach(key =&gt; url.searchParams.append(key, params[key]));
  
  const headers = {
      Authorization: 'Token ' + process.env.API_TOKEN,
      'Content-Type': 'application/x-www-form-urlencoded'
  };
  
  fetch(order_url, {
    headers
  })
    .then(response =&gt; response.json())
    .then(result =&gt; {
      console.log(result);
    })
    .catch(error =&gt; {
      console.error(error)
    })
  </code></pre>
  
  <p>The error i receive is <code>"NetworkError when attempting to fetch resource."</code>
  What would be the correct configuration for this to work on the browser?</p>