Why I won’t be using Fetch API in my apps
Shahar Talmi
2.2K27

Hello Shahar… Not sure if here is the right place to post a question, but I’ll give it a try.
I’m trying to run some simple JS functions after every request to the server. I’ve been doing this with XMLHttpRequest like so:

(function () {
var origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
this.addEventListener('load', function () {

//Do something here
someFunctionToDoSomething();

});
origOpen.apply(this, arguments);
};
})();

Is there a way to accomplish this very same global thing using the Fetch API?

P.S. I totally understand if answering doubts is not the scope here.

Like what you read? Give rogério b huss a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.