old_contents: // defining XHR function
  //
  const XHR = (url = 'http://localhost:3000/data/search.json', callback = undefined) => {
    return new Promise((resolve, reject) => {
      let request = new XMLHttpRequest();
      request.open('GET', url, true);
      request.send();
      request.onreadystatechange = () => {
        if (request.readyState === 4) {
          if (request.status === 200) {
            let parsed = JSON.parse(request.response);
            resolve(parsed);
          } else {
            reject(`XHR rejected ${request.status}: ${request.statusText}`);
          }
        } else {
          reject(`XHR rejected ${request.status}: ${request.statusText}`);
        }
      };
    });
  };
  
  // exporting function
  module.exports = {
    XHR
  };
  
  // Usage
  // XHR()
  //   .then(result => console.log(result)
  //   .then(result2 => console.log(result2)
  //   .catch(error => console.log(error);
  
new_contents: // defining XHR(request) function
  const XHR = url => {
    return new Promise((resolve, reject) => {
      let request = new XMLHttpRequest();
      request.open('GET', url, true);
      request.send();
      request.addEventListener('readystatechange', () => {
        if (request.status === 200) {
          if (request.readyState === 4) {
            resolve(JSON.parse(request.response));
          }
        } else {
          reject(`XMLHttpRequest rejected with status ${request.status}: ${request.statusText}`);
        }
      }, false);
    });
  };
  
  // exporting function
  module.exports = {
    XHR
  };
  
  // Usage
  // XHR('http://localhost:3000/data/search.json')
  //   .then(result => console.log(JSON.stringify(result, null, 2)))
  //   .catch(error => new Error(error));
  
subject: update xhr request