Fetch interceptor
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.4/fetch.js"></script>
JavaScript
// https://github.com/werk85/fetch-intercept
const fetchIntercept=function(r){function n(e){if(t[e])return t[e].exports;var o=t[e]={exports:{},id:e,loaded:!1};return r[e].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=r,n.c=t,n.p="",n(0)}([function(r,n,t){(function(n,e){"use strict";function o(r){if(Array.isArray(r)){for(var n=0,t=Array(r.length);n<r.length;n++)t[n]=r[n];return t}return Array.from(r)}function i(r){if(!r.fetch)try{t(2)}catch(n){throw Error("No fetch avaibale. Unable to register fetch-intercept")}r.fetch=function(r){return function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];return f.apply(void 0,[r].concat(t))}}(r.fetch)}function f(r){for(var n=arguments.length,t=Array(n>1?n-1:0),e=1;n>e;e++)t[e-1]=arguments[e];var i=l.reduce(function(r,n){return[n].concat(r)},[]),f=Promise.resolve(t);return i.forEach(function(r){var n=r.request,t=r.requestError;(n||t)&&(f=f.then(function(r){return n.apply(void 0,o(r))},t))}),f=f.then(function(n){return r.apply(void 0,o(n))}),i.forEach(function(r){var n=r.response,t=r.responseError;(n||t)&&(f=f.then(n,t))}),f}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol?"symbol":typeof r},c="object"===("undefined"==typeof navigator?"undefined":u(navigator))&&"ReactNative"===navigator.product,s="object"===("undefined"==typeof n?"undefined":u(n))&&!0,a="object"===("undefined"==typeof window?"undefined":u(window)),p="function"==typeof importScripts;if(c)i(e);else if(p)i(self);else if(a)i(window);else{if(!s)throw new Error("Unsupported environment for fetch-intercept");i(e)}var l=[];r.exports={register:function(r){return l.push(r),function(){var n=l.indexOf(r);n>=0&&l.splice(n,1)}},clear:function(){l=[]}}}).call(n,t(1),function(){return this}())},function(r,n){"use strict";function t(){s=!1,f.length?c=f.concat(c):a=-1,c.length&&e()}function e(){if(!s){var...