title: why is the rest api call not working?
body: <p>I am trying to fetch data by making an api call however the browser keeps showing xhr failed loading.  i cant understand the mistake in my code.</p>
  
  <pre><code>function letsgo()
  {
     var ourRequest = new XMLHttpRequest();
     ourRequest.open('GET','https://newsapi.org/v1/articles?source=techcrunch&amp;apiKey=083f90f14c7d4a8b8346a5f944dedd58',true);
  
    ourRequest.onload = function()
    {
      if (ourRequest.status &gt;= 200 &amp;&amp; ourRequest.status &lt; 400) 
      {
  
        var ourData = JSON.parse(ourRequest.responseText);
        renderHTML(ourData);
      }
      else
      {
        console.log("We connected to the server, but it returned an error.");
      }
  
    };
  
    ourRequest.onerror = function() {
        console.log("Connection error");
    };
  
    ourRequest.send(); 
  }
  </code></pre>
  
  <p>below is the function which logs the data</p>
  
  <pre><code> function renderHTML(data) {
         console.log(data);
      }
  </code></pre>