JSFiddle - React, Tailwind, and code Playground

JavaScript

var XHRListener = {
  orig_send: XMLHttpRequest.prototype.send
}
XMLHttpRequest.prototype.send = function(data) {
  if (XHRListener.onXHRComplete) {
    var orig_cb = this.onreadystatechange;
    this.onreadystatechange = function() {
      if (xhr.readyState == XMLHttpRequest.DONE) {
        XHRListener.onXHRComplete();
      }
      orig_cb();
    }
  }
  XHRListener.orig_send.apply(this, data);
}

XHRListener.onXHRComplete = function() {
  alert('completed an xhr!')
}

var xhr = new XMLHttpRequest();
xhr.open('get', 'https://www.google.com');
xhr.onreadystatechange = function() {
  if (xhr.readyState !== XMLHttpRequest.DONE) {
    return;
  }
  if (xhr.status !== 200) {
    return;
  }
  alert(xhr.responseText);
};
xhr.send();