title: How do I make an http request with fetch in node? node-fetch
body: <p>I am trying to make a request in node.  Here is my code:</p>
  
  <pre><code>fetch("http://www.test.com", options).catch(err =&gt; {
      console.error(err);
  
      return err;
    });
  </code></pre>
  
  <p>Here is the error that I get.
  <code>TypeError: Only HTTP(S) protocols are supported</code></p>
  
  <p>I have tried to create a new agent and pass it in the options like this:</p>
  
  <pre><code>const httpAgent = new http.Agent({
      keepAlive: true
  });
  const httpsAgent = new https.Agent({
      keepAlive: true
  });
  
  const options = {
      agent: function (_parsedURL) {
          if (_parsedURL.protocol == 'http:') {
              return httpAgent;
          } else {
              return httpsAgent;
          }
      }
  }
  </code></pre>
  
  <p>I still get the same error.  </p>
  
  <p>When I run this in the client, I can send an <code>http</code> or an <code>https</code> request to the same <code>fetch</code> and there isn't an issue.  Apparently it is different on with node.</p>
  
  <p>What is the best way to handle this?</p>