UNPKG

uni-http

Version:

在uniapp中发送请求和上传文件的api进行了封装

2 lines 21.2 kB
/*! For license information please see uni-http.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.uniHttp=t():e.uniHttp=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{UniAbortController:()=>u,UniHttp:()=>T,jsonToSerialize:()=>f,mergeConfig:()=>c,mergeUrl:()=>s,parseUrlParams:()=>p,removeHeaderContentType:()=>l,urlWithParams:()=>v});class r{isCompleted=!1}class n extends r{_res;_rej;promise;constructor(){super(),this.promise=new Promise(((e,t)=>{this._res=e,this._rej=t}))}complete(e){if(this.isCompleted)throw Error("Promise already completed");this._res(e),this.isCompleted=!0}completeError(e){if(this.isCompleted)throw Error("Promise already completed");this._rej(e),this.isCompleted=!0}}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}var u=function(){return e=function e(){var t,r,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,r="completer",o=new n,(r=a(r))in t?Object.defineProperty(t,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[r]=o},(t=[{key:"abort",value:function(){this.completer.isCompleted||this.completer.complete(!0)}}])&&i(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function c(e,t){var r,n,o,i,a,u,c,s,l,f,p,v,h,d,y,m,b,g,w,x,k,P,E,j,O,T,S,L={requestFunc:null!==(r=e.requestFunc)&&void 0!==r?r:t.requestFunc,baseURL:null!==(n=e.baseURL)&&void 0!==n?n:t.baseURL,url:null!==(o=e.url)&&void 0!==o?o:t.url,method:null!==(i=null!==(a=e.method)&&void 0!==a?a:t.method)&&void 0!==i?i:"GET",data:Object.assign({},t.data,e.data),params:Object.assign({},t.params,e.params),header:Object.assign({},t.header,e.header),filePath:null!==(u=e.filePath)&&void 0!==u?u:t.filePath,name:null!==(c=e.name)&&void 0!==c?c:t.name,timeout:null!==(s=e.timeout)&&void 0!==s?s:t.timeout,dataType:null!==(l=e.dataType)&&void 0!==l?l:t.dataType,responseType:null!==(f=e.responseType)&&void 0!==f?f:t.responseType,sslVerify:null!==(p=e.sslVerify)&&void 0!==p?p:t.sslVerify,withCredentials:null!==(v=e.withCredentials)&&void 0!==v?v:t.withCredentials,firstIpv4:null!==(h=e.firstIpv4)&&void 0!==h?h:t.firstIpv4,success:null!==(d=e.success)&&void 0!==d?d:t.success,fail:null!==(y=e.fail)&&void 0!==y?y:t.fail,complete:null!==(m=e.complete)&&void 0!==m?m:t.complete,fileType:null!==(b=e.fileType)&&void 0!==b?b:t.fileType,file:null!==(g=e.file)&&void 0!==g?g:t.file,files:null!==(w=e.files)&&void 0!==w?w:[],abortController:null!==(x=e.abortController)&&void 0!==x?x:t.abortController,offHeadersReceived:null!==(k=e.offHeadersReceived)&&void 0!==k?k:t.offHeadersReceived,onHeadersReceived:null!==(P=e.onHeadersReceived)&&void 0!==P?P:t.onHeadersReceived,onProgressUpdate:null!==(E=e.onProgressUpdate)&&void 0!==E?E:t.onProgressUpdate,offProgressUpdate:null!==(j=e.offProgressUpdate)&&void 0!==j?j:t.offProgressUpdate,interceptors:null!==(O=e.interceptors)&&void 0!==O?O:[]};return t.files&&(L.files=null===(T=L.files)||void 0===T?void 0:T.concat(t.files)),t.interceptors&&(L.interceptors=null===(S=L.interceptors)||void 0===S?void 0:S.concat(t.interceptors)),L}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=t.match(/^https?:\/\//);return r||t.startsWith("/")||(t="/"+t),e?r?t:e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):t}function l(e){return Object.keys(e).forEach((function(t){"content-type"===t.toLowerCase().trim()&&delete e[t]})),e}function f(e){var t="",r=function(r){var n=e[r],o=Object.prototype.toString.call(n);"[object Array]"===o?n.forEach((function(e){return t+="".concat(r,"=").concat(e,"&")})):t+="[object Object]"===o?"".concat(r,"=").concat(JSON.stringify(n),"&"):"".concat(r,"=").concat(n,"&")};for(var n in e)r(n);return t.replace(/&$/,"")}function p(e){var t={url:e,params:{}};if(!(e.indexOf("?")>=0))return t;var r=e.split("?");return t.url=r[0],r[1]?(r[1].split("&").map((function(e){return e.split("=")})).forEach((function(e){if(2===e.length){var r=e[0],n=e[1];t.params.hasOwnProperty(r)?(t.params[r]=[t.params[r]],t.params[r].push(n)):t.params[r]=n}})),t):t}function v(e){var t=p(s(e.baseURL,e.url)),r=f(Object.assign({},t.params,e.params));return r?t.url+"?"+r:t.url}function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function y(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=h(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==h(t)?t:t+""}function b(){b=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),u=new q(n||[]);return o(a,"_invoke",{value:S(e,r,u)}),a}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var p="suspendedStart",v="suspendedYield",d="executing",y="completed",m={};function g(){}function w(){}function x(){}var k={};s(k,a,(function(){return this}));var P=Object.getPrototypeOf,E=P&&P(P(U([])));E&&E!==r&&n.call(E,a)&&(k=E);var j=x.prototype=g.prototype=Object.create(k);function O(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(o,i,a,u){var c=f(e[o],e,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==h(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function S(t,r,n){var o=p;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=L(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(t,r,n);if("normal"===s.type){if(o=n.done?y:v,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function L(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,L(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function q(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function U(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(h(t)+" is not iterable")}return w.prototype=x,o(j,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:w,configurable:!0}),w.displayName=s(x,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,s(e,c,"GeneratorFunction")),e.prototype=Object.create(j),e},t.awrap=function(e){return{__await:e}},O(T.prototype),s(T.prototype,u,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new T(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},O(j),s(j,c,"Generator"),s(j,a,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=U,q.prototype={constructor:q,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:U(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function g(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function w(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){g(i,n,o,a,u,"next",e)}function u(e){g(i,n,o,a,u,"throw",e)}a(void 0)}))}}function x(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new k(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function k(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return k=function(e){this.s=e,this.n=e.next},k.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new k(e)}var P={errMsg:"request:fail cancel"};function E(e,t){return y({},Symbol.asyncIterator,(function(){return{i:0,next:function(){var r=this;return w(b().mark((function n(){var o;return b().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,!(r.i<e.length)){n.next=6;break}return o=e[r.i++],n.next=5,t(o);case 5:return n.abrupt("return",{value:o,done:!1});case 6:return n.abrupt("return",{value:null,done:!0});case 9:throw n.prev=9,n.t0=n.catch(0),n.t0;case 12:case"end":return n.stop()}}),n,null,[[0,9]])})))()}}}))}function j(e,t){return e?e.filter((function(e){return t in e&&"function"==typeof e[t]})):[]}function O(){return O=w(b().mark((function e(t){var r,o,i,a,u,c,s,f,p,h,d,y,m,g,k,O,T;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new n,o=!1,e.prev=2,i=!1,a=!1,e.prev=5,c=x(E(j(t.interceptors,"request"),(function(e){var r;return null===(r=e.request)||void 0===r?void 0:r.call(e,t)})));case 7:return e.next=9,c.next();case 9:if(!(i=!(s=e.sent).done)){e.next=21;break}if(f=s.value){e.next=13;break}return e.abrupt("continue",18);case 13:if(!0!==t.cancel){e.next=18;break}return o=!0,null===(p=f.fail)||void 0===p||p.call(f,P,t),null===(h=f.complete)||void 0===h||h.call(f,P,t),e.abrupt("break",21);case 18:i=!1,e.next=7;break;case 21:e.next=27;break;case 23:e.prev=23,e.t0=e.catch(5),a=!0,u=e.t0;case 27:if(e.prev=27,e.prev=28,!i||null==c.return){e.next=32;break}return e.next=32,c.return();case 32:if(e.prev=32,!a){e.next=35;break}throw u;case 35:return e.finish(32);case 36:return e.finish(27);case 37:e.next=42;break;case 39:e.prev=39,e.t1=e.catch(2),r.completeError(e.t1);case 42:if(!o){e.next=45;break}return r.completeError(P),e.abrupt("return",r.promise);case 45:return d=v(t),y=function(){var e=w(b().mark((function e(n){var o,i,a,u,c;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,o=!1,i=!1,e.prev=3,u=x(E(j(t.interceptors,"success"),function(){var e=w(b().mark((function e(r){return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.success(n,t);case 2:return e.abrupt("return",n=e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.next=7,u.next();case 7:if(!(o=!(c=e.sent).done)){e.next=12;break}c.value;case 9:o=!1,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),i=!0,a=e.t0;case 18:if(e.prev=18,e.prev=19,!o||null==u.return){e.next=23;break}return e.next=23,u.return();case 23:if(e.prev=23,!i){e.next=26;break}throw a;case 26:return e.finish(23);case 27:return e.finish(18);case 28:t.success?t.success(n):r.complete(n),e.next=34;break;case 31:e.prev=31,e.t1=e.catch(0),r.completeError(e.t1);case 34:case"end":return e.stop()}}),e,null,[[0,31],[3,14,18,28],[19,,23,27]])})));return function(t){return e.apply(this,arguments)}}(),m=function(){var e=w(b().mark((function e(n){var o,i,a,u,c;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,o=!1,i=!1,e.prev=3,u=x(E(j(t.interceptors,"fail"),function(){var e=w(b().mark((function e(r){var o;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null===(o=r.fail)||void 0===o?void 0:o.call(r,n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.next=7,u.next();case 7:if(!(o=!(c=e.sent).done)){e.next=12;break}c.value;case 9:o=!1,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),i=!0,a=e.t0;case 18:if(e.prev=18,e.prev=19,!o||null==u.return){e.next=23;break}return e.next=23,u.return();case 23:if(e.prev=23,!i){e.next=26;break}throw a;case 26:return e.finish(23);case 27:return e.finish(18);case 28:t.fail?t.fail(n):r.completeError(n),e.next=34;break;case 31:e.prev=31,e.t1=e.catch(0),r.completeError(e.t1);case 34:case"end":return e.stop()}}),e,null,[[0,31],[3,14,18,28],[19,,23,27]])})));return function(t){return e.apply(this,arguments)}}(),g=function(){var e=w(b().mark((function e(n){var o,i,a,u,c,s;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,i=!1,a=!1,e.prev=3,c=x(E(j(t.interceptors,"complete"),function(){var e=w(b().mark((function e(r){var o;return b().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null===(o=r.complete)||void 0===o?void 0:o.call(r,n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.next=7,c.next();case 7:if(!(i=!(s=e.sent).done)){e.next=12;break}s.value;case 9:i=!1,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),a=!0,u=e.t0;case 18:if(e.prev=18,e.prev=19,!i||null==c.return){e.next=23;break}return e.next=23,c.return();case 23:if(e.prev=23,!a){e.next=26;break}throw u;case 26:return e.finish(23);case 27:return e.finish(18);case 28:null===(o=t.complete)||void 0===o||o.call(t,n),e.next=34;break;case 31:e.prev=31,e.t1=e.catch(0),r.completeError(e.t1);case 34:case"end":return e.stop()}}),e,null,[[0,31],[3,14,18,28],[19,,23,27]])})));return function(t){return e.apply(this,arguments)}}(),t.requestFunc&&"function"==typeof t.requestFunc?t.requestFunc(d,t,y,m,g):(t.filePath||t.file||t.files&&t.files.length?(t.header=l(null!==(T=t.header)&&void 0!==T?T:{}),O=uni.uploadFile({url:d,files:t.files,fileType:t.fileType,file:t.file,filePath:t.filePath,name:t.name,header:t.header,formData:t.data,success:function(e){var t;try{t=JSON.parse(e.data)}catch(r){t=e.data}var r={statusCode:e.statusCode,header:{},cookies:[],data:t};y(r)},fail:m,complete:g})):O=uni.request({url:d,data:t.data,header:t.header,method:t.method,timeout:t.timeout,dataType:t.dataType,responseType:t.responseType,sslVerify:t.sslVerify,withCredentials:t.withCredentials,firstIpv4:t.firstIpv4,success:y,fail:m,complete:g}),null===(k=t.abortController)||void 0===k||k.completer.promise.then((function(){return O.abort()})),t.onProgressUpdate&&O.onProgressUpdate(t.onProgressUpdate),t.onHeadersReceived&&O.onHeadersReceived(t.onHeadersReceived),t.offProgressUpdate&&O.offProgressUpdate(t.offProgressUpdate),t.offHeadersReceived&&O.offHeadersReceived(t.offHeadersReceived)),e.abrupt("return",r.promise);case 51:case"end":return e.stop()}}),e,null,[[2,39],[5,23,27,37],[28,,32,36]])}))),O.apply(this,arguments)}var T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"config",void 0),this.config=t}return t=e,r=[{key:"request",value:function(e){return function(e){return O.apply(this,arguments)}(c(e,this.config))}},{key:"_request",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return"string"==typeof t?r.url=t:r=t,r.method=e,this.request(r)}},{key:"get",value:function(e,t){return this._request("GET",e,t)}},{key:"post",value:function(e,t){return this._request("POST",e,t)}},{key:"put",value:function(e,t){return this._request("PUT",e,t)}},{key:"delete",value:function(e,t){return this._request("DELETE",e,t)}},{key:"options",value:function(e,t){return this._request("OPTIONS",e,t)}},{key:"head",value:function(e,t){return this._request("HEAD",e,t)}},{key:"reace",value:function(e,t){return this._request("TRACE",e,t)}},{key:"connect",value:function(e,t){return this._request("CONNECT",e,t)}}],n=[{key:"create",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}}],r&&d(t.prototype,r),n&&d(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,n}();return t})()));