title: REST Call with node js: "Error: connect ETIMEDOUT" and "http code 0"
body: <p>I set up a REST Server and I can send http requests via Postman.
  That works fine.
  Now I am trying to send a GET request from this server to another server.</p>
  <p>Let me show you:</p>
  <pre><code>const express = require('express');
  const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
  const router = express.Router();
  
  router.get('/', (req, res, next) =&gt; {
      const http = new XMLHttpRequest();
      const url = 'https://jsonplaceholder.typicode.com/posts';
      // Postman Mock
      //const url = '...';
      http.open(&quot;GET&quot;, url);
      http.send();
  
      http.onreadystatechange = function() {
          console.log(this.readyState, this.status);
          console.log(this.statusText);
          if (this.readyState == 4 &amp;&amp; this.status == 200){
              console.log(&quot;It worked!&quot;);
              console.log(http.responseText);
          }
      }
  
      res.status(200).json({
          message: 'Handling GET requests to /product'
      });
  });
  module.exports = router;
  </code></pre>
  <p>I send a GET request via Postman to my server and that should trigger another GET request from my server to the <a href="https://jsonplaceholder.typicode.com/" rel="nofollow noreferrer">jsonplacholder</a>.
  But I get this:</p>
  <p><em>4 0</em></p>
  <p><em>Error: connect ETIMEDOUT ...
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '...',
  port: ...
  }</em></p>
  <p>There is no HTTP Code 0 ...<br />
  Besides I tried this:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;h2&gt;The XMLHttpRequest Object&lt;/h2&gt;
  
  
  &lt;script&gt;
      const Http = new XMLHttpRequest();
      const url='https://jsonplaceholder.typicode.com/posts';
      Http.open(&quot;GET&quot;, url);
      Http.send();
  
      Http.onreadystatechange = (e) =&gt; {
          console.log(&quot;TEST&quot;);
          console.log(Http.readyState, Http.status);
          console.log(Http.responseText)
      }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>In the Browser Console you can see this:<br />
  TEST<br />
  2 200<br />
  TEST<br />
  3 200<br />
  ... an the extreme long json coming from jsonplaceholder</p>
  <p>So it worked fine here.
  What am I doing wrong? And is it even possible to send a request like I tried it?</p>
  <p>Thanks for your help! :)</p>
  <p>Marc</p>