XMLHttpRequest works in browser but not in Node
<p>I'm trying to make an API call to GitHub's API.</p>

<pre><code>var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.github.com/search/users?q=mohamed3on");
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE &amp;&amp; xhr.status === 200) {
        console.log(xhr.response);
    }
}
xhr.send();
</code></pre>

<p>This code executes and returns a JSON file when run in browser.</p>

<blockquote>
  <p>{   "total_count": 1,   "incomplete_results": false,   "items": [
      {
        "login": "Mohamed3on",
        "id": 12295159,
        "avatar_url": "<a href="https://avatars.githubusercontent.com/u/12295159?v=3" rel="nofollow noreferrer">https://avatars.githubusercontent.com/u/12295159?v=3</a>",
        "gravatar_id": "",
        "url": "<a href="https://api.github.com/users/Mohamed3on" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on</a>",
        "html_url": "<a href="https://github.com/Mohamed3on" rel="nofollow noreferrer">https://github.com/Mohamed3on</a>",
        "followers_url": "<a href="https://api.github.com/users/Mohamed3on/followers" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/followers</a>",
        "following_url": "<a href="https://api.github.com/users/Mohamed3on/following" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/following</a>{/other_user}",
        "gists_url": "<a href="https://api.github.com/users/Mohamed3on/gists" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/gists</a>{/gist_id}",
        "starred_url": "<a href="https://api.github.com/users/Mohamed3on/starred" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/starred</a>{/owner}{/repo}",
        "subscriptions_url": "<a href="https://api.github.com/users/Mohamed3on/subscriptions" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/subscriptions</a>",
        "organizations_url": "<a href="https://api.github.com/users/Mohamed3on/orgs" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/orgs</a>",
        "repos_url": "<a href="https://api.github.com/users/Mohamed3on/repos" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/repos</a>",
        "events_url": "<a href="https://api.github.com/users/Mohamed3on/events" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/events</a>{/privacy}",
        "received_events_url": "<a href="https://api.github.com/users/Mohamed3on/received_events" rel="nofollow noreferrer">https://api.github.com/users/Mohamed3on/received_events</a>",
        "type": "User",
        "site_admin": false,
        "score": 49.68772
      }   ] }</p>
</blockquote>

<p>However, when I run it locally (Webstorm or Node)</p>

<pre><code>var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.github.com/search/users?q=mohamed3on");
xhr.onreadystatechange = function () {
    if (xhr.readyState === XMLHttpRequest.DONE &amp;&amp; xhr.status === 200) {
        console.log(xhr.response);
    }
}
xhr.send();
</code></pre>

<p>nothing is output in the console.</p>