JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/superagent/2.2.0/superagent.js"></script>
<body>
</body>
JavaScript
const intercept = (urlmatch, callback) => {
let send = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
this.addEventListener('readystatechange', function() {
if (this.responseURL.includes(urlmatch) && this.readyState === 4) {
callback(this);
}
}, false);
send.apply(this, arguments);
};
};
let output = response => {
document.querySelector('body').innerHTML = response.responseText;
};
intercept('httpbin.org', output);
superagent.get('https://httpbin.org/ip').end();