UNPKG

@fruitsjs/http

Version:
17 lines (14 loc) 22.9 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).fruitsjs$http={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var o=function e(n,r){t(this,e),this.status=n,this.response=r},i=function e(n,r,o,i){t(this,e),this.requestUrl=n,this.status=r,this.message=o,this.data=i,this.timestamp=Date.now()},s=function(){function e(){t(this,e),this._replyFunctions=e.initialReplyFunctions(),this.reset()}return r(e,[{key:"createReplyFn",value:function(e,t){return function(){return Promise.resolve(new o(e,t))}}},{key:"createErrorFn",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return function(){throw new i(e,t,n,r)}}},{key:"reset",value:function(){this._replyFunctions=e.initialReplyFunctions()}},{key:"registerResponse",value:function(e,t,n,r){this._replyFunctions[e][t]=this.createReplyFn(n,r)}},{key:"registerError",value:function(e,t,n,r,o){this._replyFunctions[e][t]=this.createErrorFn(t,n,r,o)}},{key:"get",value:function(e){return this.request("get",e)}},{key:"delete",value:function(e){return this.request("delete",e)}},{key:"post",value:function(e,t){return this.request("post",e)}},{key:"put",value:function(e,t){return this.request("put",e)}},{key:"request",value:function(t,n){var r=this._replyFunctions[t][n]||this._replyFunctions[t][e.ForAll];if(!r)throw new Error("Could not find any mocked function for method ".concat(t.toUpperCase()," url ").concat(n));return r()}}],[{key:"initialReplyFunctions",value:function(){return{get:{},post:{},put:{},delete:{}}}}]),e}();s.ForAll="__all";var a=function(){function e(){t(this,e),this._httpMock=new s}return r(e,[{key:"onReply",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this._httpMock.registerResponse(e,r,t,n),this}},{key:"onThrowError",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:s.ForAll;return this._httpMock.registerError(e,o,t,n,r),this}},{key:"onGetReply",value:function(e,t,n){return this.onReply("get",e,t,n)}},{key:"onGetThrowError",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("get",e,t,n,r)}},{key:"onPostReply",value:function(e,t,n){return this.onReply("post",e,t,n)}},{key:"onPostThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("post",e,t,n,r)}},{key:"onPutReply",value:function(e,t,n){return this.onReply("put",e,t,n)}},{key:"onPutThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("put",e,t,n,r)}},{key:"onDeleteReply",value:function(e,t,n){return this.onReply("delete",e,t,n)}},{key:"onDeleteThrowError",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.ForAll;return this.onThrowError("delete",e,t,n,r)}},{key:"build",value:function(){return this._httpMock}}],[{key:"create",value:function(){return new e}}]),e}(); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n((function(t){t(e.value)})).then(s,a)}u((r=r.apply(e,t||[])).next())}))}var c=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},l=Object.prototype.toString;function f(e){return"[object Array]"===l.call(e)}function p(e){return void 0===e}function d(e){return null!==e&&"object"==typeof e}function h(e){if("[object Object]"!==l.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function m(e){return"[object Function]"===l.call(e)}function v(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),f(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var y={isArray:f,isArrayBuffer:function(e){return"[object ArrayBuffer]"===l.call(e)},isBuffer:function(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:d,isPlainObject:h,isUndefined:p,isDate:function(e){return"[object Date]"===l.call(e)},isFile:function(e){return"[object File]"===l.call(e)},isBlob:function(e){return"[object Blob]"===l.call(e)},isFunction:m,isStream:function(e){return d(e)&&m(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:v,merge:function e(){var t={};function n(n,r){h(t[r])&&h(n)?t[r]=e(t[r],n):h(n)?t[r]=e({},n):f(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)v(arguments[r],n);return t},extend:function(e,t,n){return v(t,(function(t,r){e[r]=n&&"function"==typeof t?c(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}};function g(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var w=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(y.isURLSearchParams(t))r=t.toString();else{var o=[];y.forEach(t,(function(e,t){null!=e&&(y.isArray(e)?t+="[]":e=[e],y.forEach(e,(function(e){y.isDate(e)?e=e.toISOString():y.isObject(e)&&(e=JSON.stringify(e)),o.push(g(t)+"="+g(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function b(){this.handlers=[]}b.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},b.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},b.prototype.forEach=function(e){y.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var k=b,E=function(e,t){y.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},x=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},j=function(e,t,n,r,o){var i=new Error(e);return x(i,t,n,r,o)},R=y.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),y.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),y.isString(r)&&s.push("path="+r),y.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},O=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],S=y.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=y.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},T=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers,i=e.responseType;y.isFormData(r)&&delete o["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(a+":"+u)}var c,l,f=(c=e.baseURL,l=e.url,c&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(l)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(c,l):l);function p(){if(s){var r,o,a,u,c,l="getAllResponseHeaders"in s?(r=s.getAllResponseHeaders(),c={},r?(y.forEach(r.split("\n"),(function(e){if(u=e.indexOf(":"),o=y.trim(e.substr(0,u)).toLowerCase(),a=y.trim(e.substr(u+1)),o){if(c[o]&&O.indexOf(o)>=0)return;c[o]="set-cookie"===o?(c[o]?c[o]:[]).concat([a]):c[o]?c[o]+", "+a:a}})),c):c):null,f={data:i&&"text"!==i&&"json"!==i?s.response:s.responseText,status:s.status,statusText:s.statusText,headers:l,config:e,request:s};!function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(j("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}(t,n,f),s=null}}if(s.open(e.method.toUpperCase(),w(f,e.params,e.paramsSerializer),!0),s.timeout=e.timeout,"onloadend"in s?s.onloadend=p:s.onreadystatechange=function(){s&&4===s.readyState&&(0!==s.status||s.responseURL&&0===s.responseURL.indexOf("file:"))&&setTimeout(p)},s.onabort=function(){s&&(n(j("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){n(j("Network Error",e,null,s)),s=null},s.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(j(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",s)),s=null},y.isStandardBrowserEnv()){var d=(e.withCredentials||S(f))&&e.xsrfCookieName?R.read(e.xsrfCookieName):void 0;d&&(o[e.xsrfHeaderName]=d)}"setRequestHeader"in s&&y.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:s.setRequestHeader(t,e)})),y.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),i&&"json"!==i&&(s.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&s.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){s&&(s.abort(),n(e),s=null)})),r||(r=null),s.send(r)}))},A={"Content-Type":"application/x-www-form-urlencoded"};function C(e,t){!y.isUndefined(e)&&y.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var N,P={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(N=T),N),transformRequest:[function(e,t){return E(t,"Accept"),E(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(C(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)||t&&"application/json"===t["Content-Type"]?(C(t,"application/json"),function(e,t,n){if(y.isString(e))try{return(t||JSON.parse)(e),y.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!n&&"json"===this.responseType;if(o||r&&y.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw x(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};P.headers={common:{Accept:"application/json, text/plain, */*"}},y.forEach(["delete","get","head"],(function(e){P.headers[e]={}})),y.forEach(["post","put","patch"],(function(e){P.headers[e]=y.merge(A)}));var _=P,F=function(e,t,n){var r=this||_;return y.forEach(n,(function(n){e=n.call(r,e,t)})),e},U=function(e){return!(!e||!e.__CANCEL__)};function q(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var B=function(e){return q(e),e.headers=e.headers||{},e.data=F.call(e,e.data,e.headers,e.transformRequest),e.headers=y.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),y.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||_.adapter)(e).then((function(t){return q(e),t.data=F.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return U(t)||(q(e),t&&t.response&&(t.response.data=F.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},L=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return y.isPlainObject(e)&&y.isPlainObject(t)?y.merge(e,t):y.isPlainObject(t)?y.merge({},t):y.isArray(t)?t.slice():t}function u(r){y.isUndefined(t[r])?y.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}y.forEach(r,(function(e){y.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),y.forEach(o,u),y.forEach(i,(function(r){y.isUndefined(t[r])?y.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),y.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var c=r.concat(o).concat(i).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===c.indexOf(e)}));return y.forEach(l,u),n},D="Promise based HTTP client for the browser and node.js",M={test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},H={type:"git",url:"https://github.com/axios/axios.git"},I=["xhr","http","ajax","promise","node"],J={url:"https://github.com/axios/axios/issues"},z={coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},V={"./lib/adapters/http.js":"./lib/adapters/xhr.js"},G="dist/axios.min.js",X={"follow-redirects":"^1.14.0"},$=[{path:"./dist/axios.min.js",threshold:"5kB"}],W={name:"axios",version:"0.21.4",description:D,main:"index.js",scripts:M,repository:H,keywords:I,author:"Matt Zabriskie",license:"MIT",bugs:J,homepage:"https://axios-http.com",devDependencies:z,browser:V,jsdelivr:"dist/axios.min.js",unpkg:G,typings:"./index.d.ts",dependencies:X,bundlesize:$};var K,Z=(K=Object.freeze({__proto__:null,name:"axios",version:"0.21.4",description:D,main:"index.js",scripts:M,repository:H,keywords:I,author:"Matt Zabriskie",license:"MIT",bugs:J,homepage:"https://axios-http.com",devDependencies:z,browser:V,jsdelivr:"dist/axios.min.js",unpkg:G,typings:"./index.d.ts",dependencies:X,bundlesize:$,default:W}))&&K.default||K,Q={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Q[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var Y={},ee=Z.version.split(".");function te(e,t){for(var n=t?t.split("."):ee,r=e.split("."),o=0;o<3;o++){if(n[o]>r[o])return!0;if(n[o]<r[o])return!1}return!1}Q.transitional=function(e,t,n){var r=t&&te(t);function o(e,t){return"[Axios v"+Z.version+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,i,s){if(!1===e)throw new Error(o(i," has been removed in "+t));return r&&!Y[i]&&(Y[i]=!0,console.warn(o(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,s)}};var ne={isOlderVersion:te,assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:Q},re=ne.validators;function oe(e){this.defaults=e,this.interceptors={request:new k,response:new k}}oe.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=L(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&ne.assertOptions(t,{silentJSONParsing:re.transitional(re.boolean,"1.0.0"),forcedJSONParsing:re.transitional(re.boolean,"1.0.0"),clarifyTimeoutError:re.transitional(re.boolean,"1.0.0")},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!r){var s=[B,void 0];for(Array.prototype.unshift.apply(s,n),s=s.concat(i),o=Promise.resolve(e);s.length;)o=o.then(s.shift(),s.shift());return o}for(var a=e;n.length;){var u=n.shift(),c=n.shift();try{a=u(a)}catch(e){c(e);break}}try{o=B(a)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},oe.prototype.getUri=function(e){return e=L(this.defaults,e),w(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},y.forEach(["delete","get","head","options"],(function(e){oe.prototype[e]=function(t,n){return this.request(L(n||{},{method:e,url:t,data:(n||{}).data}))}})),y.forEach(["post","put","patch"],(function(e){oe.prototype[e]=function(t,n,r){return this.request(L(r||{},{method:e,url:t,data:n}))}}));var ie=oe;function se(e){this.message=e}se.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},se.prototype.__CANCEL__=!0;var ae=se;function ue(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new ae(e),t(n.reason))}))}ue.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ue.source=function(){var e;return{token:new ue((function(t){e=t})),cancel:e}};var ce=ue;function le(e){var t=new ie(e),n=c(ie.prototype.request,t);return y.extend(n,ie.prototype,t),y.extend(n,t),n}var fe=le(_);fe.Axios=ie,fe.create=function(e){return le(L(fe.defaults,e))},fe.Cancel=ae,fe.CancelToken=ce,fe.isCancel=U,fe.all=function(e){return Promise.all(e)},fe.spread=function(e){return function(t){return e.apply(null,t)}},fe.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var pe=fe,de=fe;pe.default=de;var he=pe,me={},ve=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:me;t(this,e),this._clientImpl=he.create(Object.assign({baseURL:n},r))}return r(e,[{key:"get",value:function(t,n){return u(this,void 0,void 0,(function*(){try{var r=yield this._clientImpl.get(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}}))}},{key:"post",value:function(t,n,r){return u(this,void 0,void 0,(function*(){try{var i=yield this._clientImpl.post(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}}))}},{key:"put",value:function(t,n,r){return u(this,void 0,void 0,(function*(){try{var i=yield this._clientImpl.put(t,n,r),s=i.status,a=i.data;return new o(s,a)}catch(n){throw e.mountError(t,n)}}))}},{key:"delete",value:function(t,n){return u(this,void 0,void 0,(function*(){try{var r=yield this._clientImpl.delete(t,n),i=r.status,s=r.data;return new o(i,s)}catch(n){throw e.mountError(t,n)}}))}}],[{key:"mountError",value:function(e,t){return t.response?new i(e,t.response.status,t.response.statusText,t.response.data):t.message?new i(e,0,"Request failed",t.message):t.request?new i(e,0,"Request failed",t.request):new i(e,-1,"Http Configuration error",null)}}]),e}(),ye=function(){function e(){t(this,e)}return r(e,null,[{key:"createHttpClient",value:function(e,t){return new ve(e,t)}}]),e}();e.HttpClientFactory=ye,e.HttpError=i,e.HttpMockBuilder=a,e.HttpResponse=o,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=fruitsjs.http.min.js.map