title: How to make AJAX request in Hackerrank using JavaScript?
body: <p>I open the Hackerrank example test and play around with methods one might use to make an AJAX call. <code>XMLHttpReq</code>, <code>fetch</code>, etc. None of them work; <code>XHR</code> and <code>fetch</code> methods are unavailable.</p>
  <p>First <code>fetch</code>:</p>
  <pre><code>async function myFetch() {
    let response = await fetch('https://jsonplaceholder.typicode.com/todos/1');
    let data = await response.json();
    console.log(data);
  }
  </code></pre>
  <p>Hackerrank throws an error because <code>fetch</code> is not a function. I also tried <code>window.fetch</code> and <code>global.fetch</code> to no avail.</p>
  <p>I tried <code>XHR</code>:</p>
  <pre><code>function myXHR() {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState === 4 &amp;&amp; this.status === 200) {
        console.log(this.responseText);
        // or JSON.parse(this.responseText);
      }
    };
    xmlhttp.open('GET', 'https://jsonplaceholder.typicode.com/todos/1');
    xmlhttp.send();
  }
  </code></pre>
  <p>Hackerrank says <code>XMLHttpRequest</code> is not defined.</p>
  <p>Hackerrank is executing Node.JS code, that explains why <code>XHR</code> isn't available, I have to require myself perhaps. Except I can't <code>npm install</code> anything, all I have access to is their little IDE.</p>
  <p>How do you make an AJAX call in this platform with JavaScript?</p>