title: What kind of error is this? Trying to consume an API with callbacks
body: <p>I am practicing callbacks with an API (Rick and Morty API) and using XMLHttpResquest.</p>
  
  <p>As you see, this is my code:</p>
  
  <pre><code>let XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
  let API = 'https://rickandmortyapi.com/api/character';
  
  function fetchData(url_api, callback) {
      let xhttp = new XMLHttpRequest();
      xhttp.open('GET', url_api, true);
      xhttp.onreadystatechange = function(event) {
          if(xhttp.readyState === 4) {
              if(xhttp.status === 200) {
                  callback(null, JSON.parse(xhttp.responseText))
              } else {
                  const error = new Error('Error ' + url_api);
                  return callback(error, null);
              }
          }
      }
      xhttp.send();
  }
  
  fetchData(API, function(error1, data1) {
      if (error1) return console.error(error1);
      fetchData(API + data1.results[0].id, function(error2, data2) {
          if (error2) return console.error(error2);
          fetchData(data2.origin.url, function (error3, data3) {
              if (error3) return console.error(error3);
              console.log(data1.info.count);
              console.log(data2.name);
              console.log(data3.dimension);
          });
      });
  });
  </code></pre>
  
  <p>It returns an error, but I'm not sure what type of error:</p>
  
  <blockquote>
    <p>yarn run v1.22.4 $ node src/callback/challenge.js Error: Error
    <a href="https://rickandmortyapi.com/api/character" rel="nofollow noreferrer">https://rickandmortyapi.com/api/character</a>
        at exports.XMLHttpRequest.xhttp.onreadystatechange (A:\Carrera de Backend con JavaScript\Curso de
    Asincronismo\asincronismo\src\callback\challenge.js:12:31)
        at exports.XMLHttpRequest.dispatchEvent (A:\Carrera de Backend con JavaScript\Curso de
    Asincronismo\asincronismo\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:591:25)
        at setState (A:\Carrera de Backend con JavaScript\Curso de Asincronismo\asincronismo\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:610:14)
        at exports.XMLHttpRequest.handleError (A:\Carrera de Backend con JavaScript\Curso de
    Asincronismo\asincronismo\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:532:5)
        at ClientRequest.errorHandler (A:\Carrera de Backend con JavaScript\Curso de
    Asincronismo\asincronismo\node_modules\xmlhttprequest\lib\XMLHttpRequest.js:459:14)
        at ClientRequest.emit (events.js:311:20)
        at TLSSocket.socketErrorListener (_http_client.js:426:9)
        at TLSSocket.emit (events.js:311:20)
        at emitErrorNT (internal/streams/destroy.js:92:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) Done in 1.51s.</p>
  </blockquote>
  
  <p>I understand that the if condition is not being met, but how can I solve it? Does not give me more details.</p>