(function() {
var origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
console.log('request started!');
this.addEventListener('load', function() {
console.log('request completed!');
// console.log(this)
//console.log(this._url)
//console.log(this.status)
});
origOpen.apply(this, arguments);
};
})();

This code will listen to all the XHR, fetch, and ajax requests and you can attach your functions on request start or on request status 200.

--

--

Karan Goyal
Karan Goyal

Written by Karan Goyal

Full Stack Developer, Top Rated on Upwork, Worked on 90+ jobs in past 9 months and all jobs are rated 5 stars, coding is fun, and always looking forward to code

No responses yet