UNPKG

intereq

Version:

Apply interceptors to `fetch` and create a custom request function.

3 lines (2 loc) 664 B
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.intereq=r()}(this,function(){"use strict";return function(e,r){void 0===r&&(r={});var n=r.onError;void 0===n&&(n=function(e){return Promise.reject(e)});var o=r.onRequest;void 0===o&&(o=function(e){return e});var t=r.onRequestError;void 0===t&&(t=n);var i=r.onResponse;void 0===i&&(i=function(e){return Promise.resolve(e)});var u=r.onResponseError;return void 0===u&&(u=n),function(){var r=arguments;try{var n=o.apply(null,r);return e(n.url,n).then(i).catch(u)}catch(e){return t(e)}}}}); //# sourceMappingURL=intereq.min.js.map