typeofnan-javascript-quizzes/6-promise-all-resolve-order-extra.js
/*
  - Convirtiendo una instancia de XMLHttpRequest en una Promise
*/
Convirtiendo una instancia de XMLHttpRequest en una Promise
Convirtiendo una instancia de XMLHttpRequest en una Promise
function xmlHttpRequestPromise() {
  return new Promise((resolve, reject) => {
    const BASE_URL = 'https://rickandmortyapi.com/api';
    const request = new XMLHttpRequest();
    request.addEventListener('load', (event) => {
      resolve(JSON.parse(event.target.response));
    });
    request.addEventListener('error', (event) => {
      reject(event);
    });
    request.open('GET', `${BASE_URL}/episode/1`);
    request.send();
  });
}
function xmlHttpRequestPromise ( ) { return new Promise ( ( resolve , reject ) => { const BASE_URL = 'https://rickandmortyapi.com/api' ; const request = new XMLHttpRequest ( ) ; request . addEventListener ( 'load' , ( event ) => { resolve ( JSON . parse ( event . target . response ) ) ; } ) ; request . addEventListener ( 'error' , ( event ) => { reject ( event ) ; } ) ; request . open ( 'GET' , ` ${ BASE_URL } ` ) ; request . send ( ) ; } ) ; }
Convirtiendo una instancia de XMLHttpRequest en una Promise
Convirtiendo una instancia de XMLHttpRequest en una Promise