title: Connection closed due to error Error: Unsupported protocol "undefined"
body: <p>Hi guys i am new in nodejs when i am trying to run my node js file then Am getting an error like coneection closed due to error Error: Unsupported protocol &quot;undefined&quot; don't know where i am wrong please fix my error</p>
  <p><a href="https://ibb.co/31J6xWS" rel="nofollow noreferrer">https://ibb.co/31J6xWS</a></p>
  <blockquote>
  <p>index.js</p>
  </blockquote>
  <pre><code>const http = require(&quot;http&quot;);
  const fs = require(&quot;fs&quot;);
  var requests = require(&quot;requests&quot;);
  
  
  
  const homeFile = fs.readFile(&quot;home.html&quot;, &quot;utf-8&quot;,(err)=&gt;{
      console.log(&quot;Sucessfully&quot;);
  });
  
  const server = http.createServer((req, res) =&gt; {
      if (req.url == &quot;/&quot;) {
          requests(
              &quot;{API}&quot;,
              )
              .on(&quot;data&quot;, (chunk) =&gt;{
                  console.log(chunk);
              })
              .on(&quot;end&quot;, (err) =&gt; {
                  if (err)
                      return console.log(&quot;coneection closed due to error&quot;,err);
  
                  console.log(&quot;end&quot;);
              });
      }
  })
  
  server.listen(8000,&quot;127.0.0.1&quot;)
  </code></pre>