class Unsplash {
  static getImage (frequency) {
    return new Promise((resolve, reject) => {
      // Set proper frequency in URL + screen size
      var unsplashUrl = `https://source.unsplash.com/${screen.width}x${screen.height}/`;

      switch (frequency) {
        case 'daily':
          unsplashUrl += 'daily';
          break;

        case 'weekly':
          unsplashUrl += 'weekly';
          break;
      }

      // Follow redirect to get actual image URL
      const req = new XMLHttpRequest();
      req.timeout = 2000;
      req.onreadystatechange = () => {
        if (req.readyState === 4 && (req.status >= 200 && req.status < 300)) {
          resolve(req.responseURL);
        }
      };
      req.ontimeout = (e) => {
        reject(e);
      };
      req.open('GET', unsplashUrl, true);
      req.send(null);
    });
  }
}

export default Unsplash;

@@ -473,100 +473,45 @@
     
-const req = new XMLHttpRequest();%0A      req.timeout = 2000;%0A      req.onreadystatechange = (
+fetch(unsplashUrl)%0A        .then((res
 ) =%3E
@@ -525,40 +525,28 @@
     
+  
 if (re
-q.readyState === 4
+s.ok
  && (re
-q
+s
 .sta
@@ -561,17 +561,17 @@
 00 && re
-q
+s
 .status 
@@ -590,16 +590,18 @@
         
+ 
+ 
 resolve(
@@ -606,90 +606,86 @@
 e(re
-q.responseURL);%0A        %7D%0A      %7D;%0A      req.ontimeout = (e) =%3E %7B%0A        reject(e
+s.url);%0A          %7D else %7B%0A            reject('Fetching Unsplash image failed'
 );%0A 
@@ -693,72 +693,23 @@
     
-%7D;%0A
     
-  req.open('GET', unsplashUrl, true);%0A      req.send(null
+%7D%0A        %7D
 );%0A 

Use Fetch API instead of XHR