title: HTTPS Request in a Node express route
body: <p>I tried to get a result of a https request in a route in node express but it fails with the reason: connect ETIMEOUT. Any Idea where I'm wrong?</p>
  
  <pre><code>router.get("/", async (req, res) =&gt; {
    try {
      result = await https.get('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY');
      console.log(result);
      res.send(result);
    }
    catch (err) {
      console.log(err);
    }
  });
  </code></pre>
  
  <p><strong>EDIT:</strong>
  The URL is valid and does return something when pasted in browser,</p>
  
  <p>Other endpoints in my API work fine, but they don't have a http request thought. They look like this i.e:</p>
  
  <pre><code>router.get("/", (req, res) =&gt; {
    try {
      res.sendFile("\\\\abc.local\\a$\\b$\\xyz\\001-005-877.pdf");
    }
    catch (err) {
      res.status(500).json({ err: err.toString() });
    }
  });
  </code></pre>
  
  <p><strong>EDIT:</strong>
  For completion:
  I had a typo in my index.js/ routing (app.use("/test", require("./routes/test")); which caused the timeout. 
  Then used this code:</p>
  
  <pre><code>router.get("/", (req, res) =&gt; {
    request('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY', function (error, response, body) {
      console.log('error:', error);
      console.log('statusCode:', response &amp;&amp; response.statusCode);
      console.log('body:', body);
    })
  });
  </code></pre>
  
  <p>I used the module 'request'. as <strong>Dijkstra</strong> suggested and even though his code (for express default http requests) wasn't working for me, he still provided everything needed to solve the problem, so Thank you.</p>