title: Fetch with absolute url prefix
body: <p>Most of the times I prefix <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch" rel="nofollow noreferrer">fetch</a> or <a href="https://www.npmjs.com/package/node-fetch" rel="nofollow noreferrer">node-fetch</a> with an <code>http://localhost</code> (to make it an absolute url).</p>
  
  <pre><code>import fetch from 'node-fetch';
  
  fetch('http://localhost/whatever')
  </code></pre>
  
  <p>Is there any way of avoiding the <code>localhost</code> part, other than simply placing <code>localhost</code> in a variable?</p>
  
  <pre><code>const baseUrl = 'http://localhost';
  
  fetch(`${baseUrl}/whatever`)
  </code></pre>
  
  <p><em>Very related to <a href="https://stackoverflow.com/questions/42467611/superagent-with-absolute-url-prefix">Superagent with absolute url prefix</a></em></p>