I'm having trouble finding any solutions for tracking the upload progress event of an XMLHttpRequest object inside of a Promise.
Here is an example of the code that I'm using to create async requests:
var request = function(method, url, data) {
  return new Promise(function(resolve, reject) {
    xhr.open(method, url, true);
    xhr.onload = resolve;
    xhr.onerror = reject;
    xhr.send(data);
  });
};
I'd like to have something like this:
  var r = request('POST', '/upload', data)
    .then(() => {
      console.log('completed');
    });
  r.upload.addEventListener('progress', (e) => {
    console.log('ProgressEvent: ', e);
  });
I'm trying to do this with vanilla JavaScript which is working well so far, but I'd like to figure out a clean way to do this without using any third party libraries.