request(url) {
    return new Promise(function(resolve, reject) {
      const jsonRequest= new XMLHttpRequest();
      jsonRequest.open("GET", url);
      // Only accept 200 success.
      jsonRequest.onload = function() {
        if (this.status == 200) {
          resolve(JSON.parse(jsonRequest.response));
        } else {
          reject({status: this.status, statusText: jsonRequest.statusText});
        }
      }
      // Reject all errors.
      jsonRequest.onerror = function() {
        reject({status: this.status, statusText: jsonRequest.statusText});
      }
      jsonRequest.send();
    });
  }
/**
   * Private internal API that returns a promise to the JSON response
   */
Private internal API that returns a promise to the JSON response
Private internal API that returns a promise to the JSON response
request(url) {
    return new Promise(function(resolve, reject) {
      const jsonRequest= new XMLHttpRequest();
      jsonRequest.open("GET", url);
      jsonRequest.onload = function() {
        if (this.status == 200) {
          resolve(JSON.parse(jsonRequest.response));
        } else {
          reject({status: this.status, statusText: jsonRequest.statusText});
        }
      }
      jsonRequest.onerror = function() {
        reject({status: this.status, statusText: jsonRequest.statusText});
      }
      jsonRequest.send();
    });
  }
request ( url ) { return new Promise ( function ( resolve , reject ) { const jsonRequest = new XMLHttpRequest ( ) ; jsonRequest . open ( "GET" , url ) ; jsonRequest . onload = function ( ) { if ( this . status == 200 ) { resolve ( JSON . parse ( jsonRequest . response ) ) ; } else { reject ( { status : this . status , statusText : jsonRequest . statusText } ) ; } } jsonRequest . onerror = function ( ) { reject ( { status : this . status , statusText : jsonRequest . statusText } ) ; } jsonRequest . send ( ) ; } ) ; }
Private internal API that returns a promise to the JSON response
Private internal API that returns a promise to the JSON response
// Only accept 200 success. // Reject all errors.