src/api.js
// Call Flickr's API using XHR
Call Flickr's API using XHR
Call Flickr ' s API using XHR
function flickrXHR(method, params) {
  const url = createFlickrUrl(method, params);
  const XHR = window.XDomainRequest || window.XMLHttpRequest;
  return new Promise((resolve, reject) => {
    const xhr = new XHR();
    xhr.open('get', url);
    xhr.onload = () => {
      try {
        resolve(JSON.parse(xhr.responseText));
      } catch (e) {
        reject(e);
      }
    };
    xhr.onerror = event => {
      reject(event.error);
    }
    xhr.send(null);
  });
}
function flickrXHR ( method , params ) { const url = createFlickrUrl ( method , params ) ; const XHR = window . XDomainRequest || indow. X MLHttpRequest; return new Promise ( ( resolve , reject ) => { const xhr = new XHR ( ) ; xhr . open ( 'get' , url ) ; xhr . onload = ( ) => { try { resolve ( JSON . parse ( xhr . responseText ) ) ; } catch ( e ) { reject ( e ) ; } } ; xhr . onerror = event => { reject ( event . error ) ; } xhr . send ( null ) ; } ) ; }
Call Flickr's API using XHR
Call Flickr ' s API using XHR