JSFiddle - React, Tailwind, and code Playground
JavaScript
(function () {
var originalFetch = fetch;
fetch = function() {
return originalFetch.apply(this, arguments).then(function(data) {
someFunctionToDoSomething();
return data;
});
};
function someFunctionToDoSomething() {
log("someFunctionToDoSomething called");
}
})();
log("Fetching...");
fetch("/echo/json/").then(function(result) {
log("Got result");
});
function log(msg) {
var p = document.createElement("pre");
p.appendChild(
document.createTextNode(msg)
);
document.body.appendChild(p);
}