Comparing version 1.0.0-alpha.1 to 1.0.0
@@ -1,2 +0,2 @@ | ||
const {spawn} = require('child_process'); | ||
import {spawn} from 'child_process'; | ||
@@ -3,0 +3,0 @@ const args = process.argv.slice(2); |
# Changelog | ||
## [1.0.0] - 2022-05-30 | ||
## [1.0.0] - 2022-10-04 | ||
@@ -31,2 +31,6 @@ ### Added | ||
- Added axios.formToJSON method [#4735](https://github.com/axios/axios/pull/4735) | ||
- Bower platform add data protocol [#4804](https://github.com/axios/axios/pull/4804) | ||
- Use WHATWG URL API instead of url.parse() [#4852](https://github.com/axios/axios/pull/4852) | ||
- Add ENUM containing Http Status Codes to typings [#4903](https://github.com/axios/axios/pull/4903) | ||
- Improve typing of timeout in index.d.ts [#4934](https://github.com/axios/axios/pull/4934) | ||
@@ -47,4 +51,7 @@ ### Changed | ||
- Updated Docs [#4742](https://github.com/axios/axios/pull/4742) | ||
- Refactored Axios to use ES2017 [#4787](https://github.com/axios/axios/pull/4787) | ||
### Deprecated | ||
- There are multiple deprecations, refactors and fixes provided in this release. Please read through the full release notes to see how this may impact your project and use case. | ||
@@ -82,3 +89,27 @@ ### Removed | ||
- Fixed timeout error message for http [4738](https://github.com/axios/axios/pull/4738) | ||
- Request ignores false, 0 and empty string as body values [#4785](https://github.com/axios/axios/pull/4785) | ||
- Added back missing minified builds [#4805](https://github.com/axios/axios/pull/4805) | ||
- Fixed a type error [#4815](https://github.com/axios/axios/pull/4815) | ||
- Fixed a regression bug with unsubscribing from cancel token; [#4819](https://github.com/axios/axios/pull/4819) | ||
- Remove repeated compression algorithm [#4820](https://github.com/axios/axios/pull/4820) | ||
- The error of calling extend to pass parameters [#4857](https://github.com/axios/axios/pull/4857) | ||
- SerializerOptions.indexes allows boolean | null | undefined [#4862](https://github.com/axios/axios/pull/4862) | ||
- Require interceptors to return values [#4874](https://github.com/axios/axios/pull/4874) | ||
- Removed unused imports [#4949](https://github.com/axios/axios/pull/4949) | ||
- Allow null indexes on formSerializer and paramsSerializer [#4960](https://github.com/axios/axios/pull/4960) | ||
### Chores | ||
- Set permissions for GitHub actions [#4765](https://github.com/axios/axios/pull/4765) | ||
- Included githubactions in the dependabot config [#4770](https://github.com/axios/axios/pull/4770) | ||
- Included dependency review [#4771](https://github.com/axios/axios/pull/4771) | ||
- Update security.md [#4784](https://github.com/axios/axios/pull/4784) | ||
- Remove unnecessary spaces [#4854](https://github.com/axios/axios/pull/4854) | ||
- Simplify the import path of AxiosError [#4875](https://github.com/axios/axios/pull/4875) | ||
- Fix Gitpod dead link [#4941](https://github.com/axios/axios/pull/4941) | ||
- Enable syntax highlighting for a code block [#4970](https://github.com/axios/axios/pull/4970) | ||
- Using Logo Axios in Readme.md [#4993](https://github.com/axios/axios/pull/4993) | ||
- Fix markup for note in README [#4825](https://github.com/axios/axios/pull/4825) | ||
- Fix typo and formatting, add colons [#4853](https://github.com/axios/axios/pull/4853) | ||
- Fix typo in readme [#4942](https://github.com/axios/axios/pull/4942) | ||
### Security | ||
@@ -131,1 +162,24 @@ | ||
- [Victor Augusto](https://github.com/VictorAugDB) | ||
- [neilnaveen](https://github.com/neilnaveen) | ||
- [Pavlos](https://github.com/psmoros) | ||
- [Kiryl Valkovich](https://github.com/visortelle) | ||
- [Naveen](https://github.com/naveensrinivasan) | ||
- [wenzheng](https://github.com/0x30) | ||
- [hcwhan](https://github.com/hcwhan) | ||
- [Bassel Rachid](https://github.com/basselworkforce) | ||
- [Grรฉgoire Pineau](https://github.com/lyrixx) | ||
- [felipedamin](https://github.com/felipedamin) | ||
- [Karl Horky](https://github.com/karlhorky) | ||
- [Yue JIN](https://github.com/kingyue737) | ||
- [Usman Ali Siddiqui](https://github.com/usman250994) | ||
- [WD](https://github.com/techbirds) | ||
- [Gรผnther Foidl](https://github.com/gfoidl) | ||
- [Stephen Jennings](https://github.com/jennings) | ||
- [C.T.Lin](https://github.com/chentsulin) | ||
- [mia-z](https://github.com/mia-z) | ||
- [Parth Banathia](https://github.com/Parth0105) | ||
- [parth0105pluang](https://github.com/parth0105pluang) | ||
- [Marco Weber](https://github.com/mrcwbr) | ||
- [Luca Pizzini](https://github.com/lpizzinidev) | ||
- [Willian Agostini](https://github.com/WillianAgostini) | ||
- [Huyen Nguyen](https://github.com/huyenltnguyen) |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";var e,t=function(e,t){return function(){return e.apply(t,arguments)}},r=Object.prototype.toString,n=(e=Object.create(null),function(t){var n=r.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())});function o(e){return e=e.toLowerCase(),function(t){return n(t)===e}}function i(e){return Array.isArray(e)}function s(e){return void 0===e}var a=o("ArrayBuffer");function u(e){return"number"==typeof e}function c(e){return null!==e&&"object"==typeof e}function f(e){if("object"!==n(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var l=o("Date"),p=o("File"),d=o("Blob"),h=o("FileList");function m(e){return"[object Function]"===r.call(e)}var y=o("URLSearchParams");function v(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var b,E=(b="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return b&&e instanceof b});var g,w=o("HTMLFormElement"),O=(g=Object.prototype.hasOwnProperty,function(e,t){return g.call(e,t)}),R={isArray:i,isArrayBuffer:a,isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||r.call(e)===t||m(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&a(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:u,isObject:c,isPlainObject:f,isUndefined:s,isDate:l,isFile:p,isBlob:d,isFunction:m,isStream:function(e){return c(e)&&m(e.pipe)},isURLSearchParams:y,isStandardBrowserEnv:function(){var e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:v,merge:function e(){var t={};function r(r,n){f(t[n])&&f(r)?t[n]=e(t[n],r):f(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)v(arguments[n],r);return t},extend:function(e,r,n){return v(r,(function(r,o){e[o]=n&&"function"==typeof r?t(r,n):r})),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r,n){var o,i,s,a={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)s=o[i],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==r&&Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:n,kindOfTest:o,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;if(i(e))return e;var t=e.length;if(!u(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:E,isFileList:h,forEachEntry:function(e,t){for(var r,n=(e&&e[Symbol.iterator]).call(e);(r=n.next())&&!r.done;){var o=r.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var r,n=[];null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:w,hasOwnProperty:O};function S(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}R.inherits(S,Error,{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,status:this.response&&this.response.status?this.response.status:null}}});var A=S.prototype,T={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){T[e]={value:e}})),Object.defineProperties(S,T),Object.defineProperty(A,"isAxiosError",{value:!0}),S.from=function(e,t,r,n,o,i){var s=Object.create(A);return R.toFlatObject(e,s,(function(e){return e!==Error.prototype})),S.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var j=S,x="object"==typeof self?self.FormData:window.FormData;function N(e){return R.isPlainObject(e)||R.isArray(e)}function _(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function C(e,t,r){return e?e.concat(t).map((function(e,t){return e=_(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}var B=R.toFlatObject(R,{},null,(function(e){return/^is[A-Z]/.test(e)}));var P=function(e,t,r){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new(x||FormData);var n,o=(r=R.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!R.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,s=r.dots,a=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&((n=t)&&R.isFunction(n.append)&&"FormData"===n[Symbol.toStringTag]&&n[Symbol.iterator]);if(!R.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(R.isDate(e))return e.toISOString();if(!u&&R.isBlob(e))throw new j("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(e)||R.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,n){var i=e;if(e&&!n&&"object"==typeof e)if(R.endsWith(r,"{}"))r=o?r:r.slice(0,-2),e=JSON.stringify(e);else if(R.isArray(e)&&function(e){return R.isArray(e)&&!e.some(N)}(e)||R.isFileList(e)||R.endsWith(r,"[]")&&(i=R.toArray(e)))return r=_(r),i.forEach((function(e,n){!R.isUndefined(e)&&t.append(!0===a?C([r],n,s):null===a?r:r+"[]",c(e))})),!1;return!!N(e)||(t.append(C(n,r,s),c(e)),!1)}var l=[],p=Object.assign(B,{defaultVisitor:f,convertValue:c,isVisitable:N});if(!R.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!R.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),R.forEach(r,(function(r,o){!0===(!R.isUndefined(r)&&i.call(t,r,R.isString(o)?o.trim():o,n,p))&&e(r,n?n.concat(o):[o])})),l.pop()}}(e),t};function U(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,(function(e){return t[e]}))}function D(e,t){this._pairs=[],e&&P(e,this,t)}var F=D.prototype;F.append=function(e,t){this._pairs.push([e,t])},F.toString=function(e){var t=e?function(t){return e.call(this,t,U)}:U;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var L=D;function k(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var q=function(e,t,r){if(!t)return e;var n=e.indexOf("#");-1!==n&&(e=e.slice(0,n));var o=r&&r.encode||k,i=R.isURLSearchParams(t)?t.toString():new L(t,r).toString(o);return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e};function I(){this.handlers=[]}I.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},I.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},I.prototype.clear=function(){this.handlers&&(this.handlers=[])},I.prototype.forEach=function(e){R.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var M=I,H=function(e,t){R.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},J={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},V={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:L,FormData:FormData,Blob:Blob},protocols:["http","https","file","blob","url"]};var z=function(e){function t(e,r,n,o){var i=e[o++],s=Number.isFinite(+i),a=o>=e.length;return i=!i&&R.isArray(n)?n.length:i,a?(R.hasOwnProperty(n,i)?n[i]=[n[i],r]:n[i]=r,!s):(n[i]&&R.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&R.isArray(n[i])&&(n[i]=function(e){var t,r,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)n[r=o[t]]=e[r];return n}(n[i])),!s)}if(R.isFormData(e)&&R.isFunction(e.entries)){var r={};return R.forEachEntry(e,(function(e,n){t(function(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),n,r,0)})),r}return null},W=R.isStandardBrowserEnv()?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),R.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),R.isString(n)&&s.push("path="+n),R.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(){}},X=function(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t},K=["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"],$=R.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=R.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0};function Q(e,t,r){j.call(this,null==e?"canceled":e,j.ERR_CANCELED,t,r),this.name="CanceledError"}R.inherits(Q,j,{__CANCEL__:!0});var G=Q,Y=function(e){return new Promise((function(t,r){var n,o=e.data,i=e.headers,s=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}R.isFormData(o)&&R.isStandardBrowserEnv()&&delete i["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(c+":"+f)}var l=X(e.baseURL,e.url);function p(){if(u){var n,o,i,c,f,l="getAllResponseHeaders"in u?(n=u.getAllResponseHeaders(),f={},n?(R.forEach(n.split("\n"),(function(e){if(c=e.indexOf(":"),o=R.trim(e.slice(0,c)).toLowerCase(),i=R.trim(e.slice(c+1)),o){if(f[o]&&K.indexOf(o)>=0)return;f[o]="set-cookie"===o?(f[o]?f[o]:[]).concat([i]):f[o]?f[o]+", "+i:i}})),f):f):null;!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new j("Request failed with status code "+r.status,[j.ERR_BAD_REQUEST,j.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:s&&"text"!==s&&"json"!==s?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:l,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),q(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(new j("Request aborted",j.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new j("Network Error",j.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",n=e.transitional||J;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new j(t,n.clarifyTimeoutError?j.ETIMEDOUT:j.ECONNABORTED,e,u)),u=null},R.isStandardBrowserEnv()){var d=(e.withCredentials||$(l))&&e.xsrfCookieName?W.read(e.xsrfCookieName):void 0;d&&(i[e.xsrfHeaderName]=d)}"setRequestHeader"in u&&R.forEach(i,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete i[t]:u.setRequestHeader(t,e)})),R.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),s&&"json"!==s&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(t){u&&(r(!t||t.type?new G(null,e,req):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null);var h,m=(h=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&h[1]||"";m&&-1===V.protocols.indexOf(m)?r(new j("Unsupported protocol "+m+":",j.ERR_BAD_REQUEST,e)):u.send(o)}))},Z={"Content-Type":"application/x-www-form-urlencoded"};function ee(e,t){!R.isUndefined(e)&&R.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var te,re={transitional:J,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(te=Y),te),transformRequest:[function(e,t){H(t,"Accept"),H(t,"Content-Type");var r,n=t&&t["Content-Type"]||"",o=n.indexOf("application/json")>-1,i=R.isObject(e);if(i&&R.isHTMLForm(e)&&(e=new FormData(e)),R.isFormData(e))return o&&o?JSON.stringify(z(e)):e;if(R.isArrayBuffer(e)||R.isBuffer(e)||R.isStream(e)||R.isFile(e)||R.isBlob(e))return e;if(R.isArrayBufferView(e))return e.buffer;if(R.isURLSearchParams(e))return ee(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(i){if(-1!==n.indexOf("application/x-www-form-urlencoded"))return function(e,t){return P(e,new V.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return V.isNode&&R.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=R.isFileList(e))||n.indexOf("multipart/form-data")>-1){var s=this.env&&this.env.FormData;return P(r?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||o?(ee(t,"application/json"),function(e,t,r){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||re.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&R.isString(e)&&(r&&!this.responseType||n)){var o=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw j.from(e,j.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:V.classes.FormData,Blob:V.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};R.forEach(["delete","get","head"],(function(e){re.headers[e]={}})),R.forEach(["post","put","patch"],(function(e){re.headers[e]=R.merge(Z)}));var ne=re,oe=function(e,t,r,n){var o=this||ne;return R.forEach(n,(function(n){e=n.call(o,e,t,r)})),e},ie=function(e){return!(!e||!e.__CANCEL__)};function se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new G}var ae=function(e){return se(e),e.headers=e.headers||{},e.data=oe.call(e,e.data,e.headers,null,e.transformRequest),H(e.headers,"Accept"),H(e.headers,"Content-Type"),e.headers=R.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),R.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||ne.adapter)(e).then((function(t){return se(e),t.data=oe.call(e,t.data,t.headers,t.status,e.transformResponse),t}),(function(t){return ie(t)||(se(e),t&&t.response&&(t.response.data=oe.call(e,t.response.data,t.response.headers,t.response.status,e.transformResponse))),Promise.reject(t)}))},ue=function(e,t){t=t||{};var r={};function n(e,t){return R.isPlainObject(e)&&R.isPlainObject(t)?R.merge(e,t):R.isPlainObject(t)?R.merge({},t):R.isArray(t)?t.slice():t}function o(r){return R.isUndefined(t[r])?R.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function i(e){if(!R.isUndefined(t[e]))return n(void 0,t[e])}function s(r){return R.isUndefined(t[r])?R.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function a(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return R.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,n=t(e);R.isUndefined(n)&&t!==a||(r[e]=n)})),r},ce="1.0.0-alpha.1",fe=ce,le={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){le[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var pe={};le.transitional=function(e,t,r){function n(e,t){return"[Axios v"+fe+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,i){if(!1===e)throw new j(n(o," has been removed"+(t?" in "+t:"")),j.ERR_DEPRECATED);return t&&!pe[o]&&(pe[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var de={assertOptions:function(e,t,r){if("object"!=typeof e)throw new j("options must be an object",j.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new j("option "+i+" must be "+u,j.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new j("Unknown option "+i,j.ERR_BAD_OPTION)}},validators:le},he=de.validators;function me(e){this.defaults=e,this.interceptors={request:new M,response:new M}}me.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=ue(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&de.assertOptions(r,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!o){var a=[ae,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),i=Promise.resolve(t);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=t;n.length;){var c=n.shift(),f=n.shift();try{u=c(u)}catch(e){f(e);break}}try{i=ae(u)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},me.prototype.getUri=function(e){e=ue(this.defaults,e);var t=X(e.baseURL,e.url);return q(t,e.params,e.paramsSerializer)},R.forEach(["delete","get","head","options"],(function(e){me.prototype[e]=function(t,r){return this.request(ue(r||{},{method:e,url:t,data:(r||{}).data}))}})),R.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(ue(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}me.prototype[e]=t(),me.prototype[e+"Form"]=t(!0)}));var ye=me;function ve(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){for(var t=r._listeners.length;t-- >0;)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new G(e,n,o),t(r.reason))}))}ve.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ve.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},ve.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},ve.source=function(){var e;return{token:new ve((function(t){e=t})),cancel:e}};var be=ve;var Ee=function e(r){var n=new ye(r),o=t(ye.prototype.request,n);return R.extend(o,ye.prototype,n),R.extend(o,n),o.create=function(t){return e(ue(r,t))},o}(ne);Ee.Axios=ye,Ee.CanceledError=G,Ee.CancelToken=be,Ee.isCancel=ie,Ee.VERSION=ce,Ee.toFormData=P,Ee.AxiosError=j,Ee.Cancel=Ee.CanceledError,Ee.all=function(e){return Promise.all(e)},Ee.spread=function(e){return function(t){return e.apply(null,t)}},Ee.isAxiosError=function(e){return R.isObject(e)&&!0===e.isAxiosError},Ee.formToJSON=function(e){return z(R.isHTMLForm(e)?new FormData(e):e)};var ge=Ee,we=Ee;return ge.default=we,ge})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(t){return e="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},e(t)}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),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){return function(){return e.apply(t,arguments)}}var i,s=Object.prototype.toString,a=Object.getPrototypeOf,u=(i=Object.create(null),function(e){var t=s.call(e);return i[t]||(i[t]=t.slice(8,-1).toLowerCase())}),c=function(e){return e=e.toLowerCase(),function(t){return u(t)===e}},f=function(t){return function(n){return e(n)===t}},l=Array.isArray,d=f("undefined");var h=c("ArrayBuffer");var p=f("string"),m=f("function"),v=f("number"),y=function(t){return null!==t&&"object"===e(t)},b=function(e){if("object"!==u(e))return!1;var t=a(e);return null===t||t===Object.prototype},g=c("Date"),E=c("File"),w=c("Blob"),O=c("FileList"),R=c("URLSearchParams");function S(t,n){var r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=i.allOwnKeys,a=void 0!==s&&s;if(null!=t)if("object"!==e(t)&&(t=[t]),l(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{var u,c=a?Object.getOwnPropertyNames(t):Object.keys(t),f=c.length;for(r=0;r<f;r++)u=c[r],n.call(null,t[u],u,t)}}var A,j=(A="undefined"!=typeof Uint8Array&&a(Uint8Array),function(e){return A&&e instanceof A}),T=c("HTMLFormElement"),x=function(e){var t=Object.prototype.hasOwnProperty;return function(e,n){return t.call(e,n)}}(),C=c("RegExp"),N=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};S(n,(function(n,o){!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},P={isArray:l,isArrayBuffer:h,isBuffer:function(e){return null!==e&&!d(e)&&null!==e.constructor&&!d(e.constructor)&&m(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||s.call(e)===t||m(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer)},isString:p,isNumber:v,isBoolean:function(e){return!0===e||!1===e},isObject:y,isPlainObject:b,isUndefined:d,isDate:g,isFile:E,isBlob:w,isRegExp:C,isFunction:m,isStream:function(e){return y(e)&&m(e.pipe)},isURLSearchParams:R,isTypedArray:j,isFileList:O,forEach:S,merge:function e(){for(var t={},n=function(n,r){b(t[r])&&b(n)?t[r]=e(t[r],n):b(n)?t[r]=e({},n):l(n)?t[r]=n.slice():t[r]=n},r=0,o=arguments.length;r<o;r++)arguments[r]&&S(arguments[r],n);return t},extend:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.allOwnKeys;return S(t,(function(t,r){n&&m(t)?e[r]=o(t,n):e[r]=t}),{allOwnKeys:i}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var o,i,s,u={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)s=o[i],r&&!r(s,e,t)||u[s]||(t[s]=e[s],u[s]=!0);e=!1!==n&&a(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:u,kindOfTest:c,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(l(e))return e;var t=e.length;if(!v(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var o=n.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:T,hasOwnProperty:x,hasOwnProp:x,reduceDescriptors:N,freezeMethods:function(e){N(e,(function(t,n){var r=e[n];m(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not read-only method '"+n+"'")}))}))},toObjectSet:function(e,t){var n={},r=function(e){e.forEach((function(e){n[e]=!0}))};return l(e)?r(e):r(String(e).split(t)),n},toCamelCase:function(e){return e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))},noop:function(){},toFiniteNumber:function(e,t){return e=+e,Number.isFinite(e)?e:t}};function _(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}P.inherits(_,Error,{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,status:this.response&&this.response.status?this.response.status:null}}});var B=_.prototype,D={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){D[e]={value:e}})),Object.defineProperties(_,D),Object.defineProperty(B,"isAxiosError",{value:!0}),_.from=function(e,t,n,r,o,i){var s=Object.create(B);return P.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(function(e){return"isAxiosError"!==e})),_.call(s,e.message,t,n,r,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var F="object"==("undefined"==typeof self?"undefined":e(self))?self.FormData:window.FormData;function U(e){return P.isPlainObject(e)||P.isArray(e)}function k(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function L(e,t,n){return e?e.concat(t).map((function(e,t){return e=k(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var q=P.toFlatObject(P,{},null,(function(e){return/^is[A-Z]/.test(e)}));function z(t,n,r){if(!P.isObject(t))throw new TypeError("target must be an object");n=n||new(F||FormData);var o,i=(r=P.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!P.isUndefined(t[e])}))).metaTokens,s=r.visitor||l,a=r.dots,u=r.indexes,c=(r.Blob||"undefined"!=typeof Blob&&Blob)&&((o=n)&&P.isFunction(o.append)&&"FormData"===o[Symbol.toStringTag]&&o[Symbol.iterator]);if(!P.isFunction(s))throw new TypeError("visitor must be a function");function f(e){if(null===e)return"";if(P.isDate(e))return e.toISOString();if(!c&&P.isBlob(e))throw new _("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(e)||P.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(t,r,o){var s=t;if(t&&!o&&"object"===e(t))if(P.endsWith(r,"{}"))r=i?r:r.slice(0,-2),t=JSON.stringify(t);else if(P.isArray(t)&&function(e){return P.isArray(e)&&!e.some(U)}(t)||P.isFileList(t)||P.endsWith(r,"[]")&&(s=P.toArray(t)))return r=k(r),s.forEach((function(e,t){!P.isUndefined(e)&&n.append(!0===u?L([r],t,a):null===u?r:r+"[]",f(e))})),!1;return!!U(t)||(n.append(L(o,r,a),f(t)),!1)}var d=[],h=Object.assign(q,{defaultVisitor:l,convertValue:f,isVisitable:U});if(!P.isObject(t))throw new TypeError("data must be an object");return function e(t,r){if(!P.isUndefined(t)){if(-1!==d.indexOf(t))throw Error("Circular reference detected in "+r.join("."));d.push(t),P.forEach(t,(function(t,o){!0===(!P.isUndefined(t)&&s.call(n,t,P.isString(o)?o.trim():o,r,h))&&e(t,r?r.concat(o):[o])})),d.pop()}}(t),n}function I(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function M(e,t){this._pairs=[],e&&z(e,this,t)}var J=M.prototype;function H(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function V(e,t,n){if(!t)return e;var r=e.indexOf("#");-1!==r&&(e=e.slice(0,r));var o=n&&n.encode||H,i=P.isURLSearchParams(t)?t.toString():new M(t,n).toString(o);return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}J.append=function(e,t){this._pairs.push([e,t])},J.toString=function(e){var t=e?function(t){return e.call(this,t,I)}:I;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var W,K=function(){function e(){t(this,e),this.handlers=[]}return r(e,[{key:"use",value: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}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){P.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}]),e}(),X={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$="undefined"!=typeof URLSearchParams?URLSearchParams:M,Q=FormData,G=("undefined"==typeof navigator||"ReactNative"!==(W=navigator.product)&&"NativeScript"!==W&&"NS"!==W)&&"undefined"!=typeof window&&"undefined"!=typeof document,Y={isBrowser:!0,classes:{URLSearchParams:$,FormData:Q,Blob:Blob},isStandardBrowserEnv:G,protocols:["http","https","file","blob","url","data"]};function Z(e){function t(e,n,r,o){var i=e[o++],s=Number.isFinite(+i),a=o>=e.length;return i=!i&&P.isArray(r)?r.length:i,a?(P.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!s):(r[i]&&P.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&P.isArray(r[i])&&(r[i]=function(e){var t,n,r={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)r[n=o[t]]=e[n];return r}(r[i])),!s)}if(P.isFormData(e)&&P.isFunction(e.entries)){var n={};return P.forEachEntry(e,(function(e,r){t(function(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),r,n,0)})),n}return null}var ee=Y.isStandardBrowserEnv?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),P.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),P.isString(r)&&s.push("path="+r),P.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(){}};function te(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var ne=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=P.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0};function re(e,t,n){_.call(this,null==e?"canceled":e,_.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(re,_,{__CANCEL__:!0});var oe=P.toObjectSet(["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"]),ie=Symbol("internals"),se=Symbol("defaults");function ae(e){return e&&String(e).trim().toLowerCase()}function ue(e){return!1===e||null==e?e:String(e)}function ce(e,t,n,r){return P.isFunction(r)?r.call(this,t,n):P.isString(t)?P.isString(r)?-1!==t.indexOf(r):P.isRegExp(r)?r.test(t):void 0:void 0}function fe(e,t){t=t.toLowerCase();for(var n,r=Object.keys(e),o=r.length;o-- >0;)if(t===(n=r[o]).toLowerCase())return n;return null}function le(e,t){e&&this.set(e),this[se]=t||null}function de(e,t){var n=0,r=function(e,t){e=e||10;var n,r=new Array(e),o=new Array(e),i=0,s=0;return t=void 0!==t?t:1e3,function(a){var u=Date.now(),c=o[s];n||(n=u),r[i]=a,o[i]=u;for(var f=s,l=0;f!==i;)l+=r[f++],f%=e;if((i=(i+1)%e)===s&&(s=(s+1)%e),!(u-n<t)){var d=c&&u-c;return d?Math.round(1e3*l/d):void 0}}}(50,250);return function(o){var i=o.loaded,s=o.lengthComputable?o.total:void 0,a=i-n,u=r(a);n=i;var c={loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:u||void 0,estimated:u&&s&&i<=s?(s-i)/u:void 0};c[t?"download":"upload"]=!0,e(c)}}function he(e){return new Promise((function(t,n){var r,o=e.data,i=le.from(e.headers).normalize(),s=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(r),e.signal&&e.signal.removeEventListener("abort",r)}P.isFormData(o)&&Y.isStandardBrowserEnv&&i.setContentType(!1);var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(c+":"+f))}var l=te(e.baseURL,e.url);function d(){if(u){var r=le.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders());!function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new _("Request failed with status code "+n.status,[_.ERR_BAD_REQUEST,_.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),a()}),(function(e){n(e),a()}),{data:s&&"text"!==s&&"json"!==s?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:r,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),V(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(d)},u.onabort=function(){u&&(n(new _("Request aborted",_.ECONNABORTED,e,u)),u=null)},u.onerror=function(){n(new _("Network Error",_.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||X;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new _(t,r.clarifyTimeoutError?_.ETIMEDOUT:_.ECONNABORTED,e,u)),u=null},Y.isStandardBrowserEnv){var h=(e.withCredentials||ne(l))&&e.xsrfCookieName&&ee.read(e.xsrfCookieName);h&&i.set(e.xsrfHeaderName,h)}void 0===o&&i.setContentType(null),"setRequestHeader"in u&&P.forEach(i.toJSON(),(function(e,t){u.setRequestHeader(t,e)})),P.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),s&&"json"!==s&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",de(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",de(e.onUploadProgress)),(e.cancelToken||e.signal)&&(r=function(t){u&&(n(!t||t.type?new re(null,e,u):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(r),e.signal&&(e.signal.aborted?r():e.signal.addEventListener("abort",r)));var p,m=(p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&p[1]||"";m&&-1===Y.protocols.indexOf(m)?n(new _("Unsupported protocol "+m+":",_.ERR_BAD_REQUEST,e)):u.send(o||null)}))}Object.assign(le.prototype,{set:function(e,t,n){var r=this;function o(e,t,n){var o=ae(t);if(!o)throw new Error("header name must be a non-empty string");var i=fe(r,o);(!i||!0===n||!1!==r[i]&&!1!==n)&&(e=P.isArray(e)?e.map(ue):ue(e),r[i||t]=e)}return P.isPlainObject(e)?P.forEach(e,(function(e,n){o(e,n,t)})):o(t,e,n),this},get:function(e,t){if(e=ae(e)){var n=fe(this,e);if(n){var r=this[n];if(!t)return r;if(!0===t)return function(e){for(var t,n=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=r.exec(e);)n[t[1]]=t[2];return n}(r);if(P.isFunction(t))return t.call(this,r,n);if(P.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}},has:function(e,t){if(e=ae(e)){var n=fe(this,e);return!(!n||t&&!ce(0,this[n],n,t))}return!1},delete:function(e,t){var n=this,r=!1;function o(e){if(e=ae(e)){var o=fe(n,e);!o||t&&!ce(0,n[o],o,t)||(delete n[o],r=!0)}}return P.isArray(e)?e.forEach(o):o(e),r},clear:function(){return Object.keys(this).forEach(this.delete.bind(this))},normalize:function(e){var t=this,n={};return P.forEach(this,(function(r,o){var i=fe(n,o);if(i)return t[i]=ue(r),void delete t[o];var s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))}(o):String(o).trim();s!==o&&delete t[o],t[s]=ue(r),n[s]=!0})),this},toJSON:function(){var e=Object.create(null);return P.forEach(Object.assign({},this[se]||null,this),(function(t,n){null!=t&&!1!==t&&(e[n]=P.isArray(t)?t.join(", "):t)})),e}}),Object.assign(le,{from:function(e){return P.isString(e)?new this((i={},(t=e)&&t.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||i[n]&&oe[n]||("set-cookie"===n?i[n]?i[n].push(r):i[n]=[r]:i[n]=i[n]?i[n]+", "+r:r)})),i)):e instanceof this?e:new this(e);var t,n,r,o,i},accessor:function(e){var t=(this[ie]=this[ie]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=ae(e);t[r]||(!function(e,t){var n=P.toCamelCase(" "+t);["get","set","has"].forEach((function(r){Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return P.isArray(e)?e.forEach(r):r(e),this}}),le.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),P.freezeMethods(le.prototype),P.freezeMethods(le);var pe={http:he,xhr:he},me=function(e){if(P.isString(e)){var t=pe[e];if(!e)throw Error(P.hasOwnProp(e)?"Adapter '".concat(e,"' is not available in the build"):"Can not resolve adapter '".concat(e,"'"));return t}if(!P.isFunction(e))throw new TypeError("adapter is not a function");return e},ve={"Content-Type":"application/x-www-form-urlencoded"};var ye,be={transitional:X,adapter:("undefined"!=typeof XMLHttpRequest?ye=me("xhr"):"undefined"!=typeof process&&"process"===P.kindOf(process)&&(ye=me("http")),ye),transformRequest:[function(e,t){var n,r=t.getContentType()||"",o=r.indexOf("application/json")>-1,i=P.isObject(e);if(i&&P.isHTMLForm(e)&&(e=new FormData(e)),P.isFormData(e))return o&&o?JSON.stringify(Z(e)):e;if(P.isArrayBuffer(e)||P.isBuffer(e)||P.isStream(e)||P.isFile(e)||P.isBlob(e))return e;if(P.isArrayBufferView(e))return e.buffer;if(P.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return z(e,new Y.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return Y.isNode&&P.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=P.isFileList(e))||r.indexOf("multipart/form-data")>-1){var s=this.env&&this.env.FormData;return z(n?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||be.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&P.isString(e)&&(n&&!this.responseType||r)){var o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw _.from(e,_.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Y.classes.FormData,Blob:Y.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};function ge(e,t){var n=this||be,r=t||n,o=le.from(r.headers),i=r.data;return P.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function Ee(e){return!(!e||!e.__CANCEL__)}function we(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new re}function Oe(e){return we(e),e.headers=le.from(e.headers),e.data=ge.call(e,e.transformRequest),(e.adapter||be.adapter)(e).then((function(t){return we(e),t.data=ge.call(e,e.transformResponse,t),t.headers=le.from(t.headers),t}),(function(t){return Ee(t)||(we(e),t&&t.response&&(t.response.data=ge.call(e,e.transformResponse,t.response),t.response.headers=le.from(t.response.headers))),Promise.reject(t)}))}function Re(e,t){t=t||{};var n={};function r(e,t){return P.isPlainObject(e)&&P.isPlainObject(t)?P.merge(e,t):P.isPlainObject(t)?P.merge({},t):P.isArray(t)?t.slice():t}function o(n){return P.isUndefined(t[n])?P.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function i(e){if(!P.isUndefined(t[e]))return r(void 0,t[e])}function s(n){return P.isUndefined(t[n])?P.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function a(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return P.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,r=t(e);P.isUndefined(r)&&t!==a||(n[e]=r)})),n}P.forEach(["delete","get","head"],(function(e){be.headers[e]={}})),P.forEach(["post","put","patch"],(function(e){be.headers[e]=P.merge(ve)}));var Se="1.0.0",Ae={};["object","boolean","number","function","string","symbol"].forEach((function(t,n){Ae[t]=function(r){return e(r)===t||"a"+(n<1?"n ":" ")+t}}));var je={};Ae.transitional=function(e,t,n){function r(e,t){return"[Axios v1.0.0] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,o,i){if(!1===e)throw new _(r(o," has been removed"+(t?" in "+t:"")),_.ERR_DEPRECATED);return t&&!je[o]&&(je[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Te={assertOptions:function(t,n,r){if("object"!==e(t))throw new _("options must be an object",_.ERR_BAD_OPTION_VALUE);for(var o=Object.keys(t),i=o.length;i-- >0;){var s=o[i],a=n[s];if(a){var u=t[s],c=void 0===u||a(u,s,t);if(!0!==c)throw new _("option "+s+" must be "+c,_.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new _("Unknown option "+s,_.ERR_BAD_OPTION)}},validators:Ae},xe=Te.validators,Ce=function(){function e(n){t(this,e),this.defaults=n,this.interceptors={request:new K,response:new K}}return r(e,[{key:"request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var n=(t=Re(this.defaults,t)).transitional;void 0!==n&&Te.assertOptions(n,{silentJSONParsing:xe.transitional(xe.boolean),forcedJSONParsing:xe.transitional(xe.boolean),clarifyTimeoutError:xe.transitional(xe.boolean)},!1),t.method=(t.method||this.defaults.method||"get").toLowerCase();var r=t.headers&&P.merge(t.headers.common,t.headers[t.method]);r&&P.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),t.headers=new le(t.headers,r);var o=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));var s,a=[];this.interceptors.response.forEach((function(e){a.push(e.fulfilled,e.rejected)}));var u,c=0;if(!i){var f=[Oe.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,a),u=f.length,s=Promise.resolve(t);c<u;)s=s.then(f[c++],f[c++]);return s}u=o.length;var l=t;for(c=0;c<u;){var d=o[c++],h=o[c++];try{l=d(l)}catch(e){h.call(this,e);break}}try{s=Oe.call(this,l)}catch(e){return Promise.reject(e)}for(c=0,u=a.length;c<u;)s=s.then(a[c++],a[c++]);return s}},{key:"getUri",value:function(e){return V(te((e=Re(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();P.forEach(["delete","get","head","options"],(function(e){Ce.prototype[e]=function(t,n){return this.request(Re(n||{},{method:e,url:t,data:(n||{}).data}))}})),P.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(Re(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Ce.prototype[e]=t(),Ce.prototype[e+"Form"]=t(!0)}));var Ne=function(){function e(n){if(t(this,e),"function"!=typeof n)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var o=this;this.promise.then((function(e){if(o._listeners){for(var t=o._listeners.length;t-- >0;)o._listeners[t](e);o._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){o.subscribe(e),t=e})).then(e);return n.cancel=function(){o.unsubscribe(t)},n},n((function(e,t,n){o.reason||(o.reason=new re(e,t,n),r(o.reason))}))}return r(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}}],[{key:"source",value:function(){var t;return{token:new e((function(e){t=e})),cancel:t}}}]),e}();var Pe=function e(t){var n=new Ce(t),r=o(Ce.prototype.request,n);return P.extend(r,Ce.prototype,n,{allOwnKeys:!0}),P.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Re(t,n))},r}(be);return Pe.Axios=Ce,Pe.CanceledError=re,Pe.CancelToken=Ne,Pe.isCancel=Ee,Pe.VERSION=Se,Pe.toFormData=z,Pe.AxiosError=_,Pe.Cancel=Pe.CanceledError,Pe.all=function(e){return Promise.all(e)},Pe.spread=function(e){return function(t){return e.apply(null,t)}},Pe.isAxiosError=function(e){return P.isObject(e)&&!0===e.isAxiosError},Pe.formToJSON=function(e){return Z(P.isHTMLForm(e)?new FormData(e):e)},Pe})); | ||
//# sourceMappingURL=axios.min.js.map |
@@ -1,2 +0,2 @@ | ||
var e,t=function(e,t){return function(){return e.apply(t,arguments)}},r=Object.prototype.toString,n=(e=Object.create(null),function(t){var n=r.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())});function o(e){return e=e.toLowerCase(),function(t){return n(t)===e}}function i(e){return Array.isArray(e)}function s(e){return void 0===e}var a=o("ArrayBuffer");function u(e){return"number"==typeof e}function c(e){return null!==e&&"object"==typeof e}function f(e){if("object"!==n(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var l=o("Date"),p=o("File"),d=o("Blob"),h=o("FileList");function m(e){return"[object Function]"===r.call(e)}var y=o("URLSearchParams");function v(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var E,b=(E="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return E&&e instanceof E});var g,w=o("HTMLFormElement"),O=(g=Object.prototype.hasOwnProperty,function(e,t){return g.call(e,t)}),R={isArray:i,isArrayBuffer:a,isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||r.call(e)===t||m(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&a(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:u,isObject:c,isPlainObject:f,isUndefined:s,isDate:l,isFile:p,isBlob:d,isFunction:m,isStream:function(e){return c(e)&&m(e.pipe)},isURLSearchParams:y,isStandardBrowserEnv:function(){var e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:v,merge:function e(){var t={};function r(r,n){f(t[n])&&f(r)?t[n]=e(t[n],r):f(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)v(arguments[n],r);return t},extend:function(e,r,n){return v(r,(function(r,o){e[o]=n&&"function"==typeof r?t(r,n):r})),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r,n){var o,i,s,a={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)s=o[i],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==r&&Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:n,kindOfTest:o,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;if(i(e))return e;var t=e.length;if(!u(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:b,isFileList:h,forEachEntry:function(e,t){for(var r,n=(e&&e[Symbol.iterator]).call(e);(r=n.next())&&!r.done;){var o=r.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var r,n=[];null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:w,hasOwnProperty:O};function S(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}R.inherits(S,Error,{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,status:this.response&&this.response.status?this.response.status:null}}});var A=S.prototype,T={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){T[e]={value:e}})),Object.defineProperties(S,T),Object.defineProperty(A,"isAxiosError",{value:!0}),S.from=function(e,t,r,n,o,i){var s=Object.create(A);return R.toFlatObject(e,s,(function(e){return e!==Error.prototype})),S.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var j=S,N="object"==typeof self?self.FormData:window.FormData;function _(e){return R.isPlainObject(e)||R.isArray(e)}function x(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function C(e,t,r){return e?e.concat(t).map((function(e,t){return e=x(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}var B=R.toFlatObject(R,{},null,(function(e){return/^is[A-Z]/.test(e)}));var P=function(e,t,r){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new(N||FormData);var n,o=(r=R.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!R.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,s=r.dots,a=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&((n=t)&&R.isFunction(n.append)&&"FormData"===n[Symbol.toStringTag]&&n[Symbol.iterator]);if(!R.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(R.isDate(e))return e.toISOString();if(!u&&R.isBlob(e))throw new j("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(e)||R.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,n){var i=e;if(e&&!n&&"object"==typeof e)if(R.endsWith(r,"{}"))r=o?r:r.slice(0,-2),e=JSON.stringify(e);else if(R.isArray(e)&&function(e){return R.isArray(e)&&!e.some(_)}(e)||R.isFileList(e)||R.endsWith(r,"[]")&&(i=R.toArray(e)))return r=x(r),i.forEach((function(e,n){!R.isUndefined(e)&&t.append(!0===a?C([r],n,s):null===a?r:r+"[]",c(e))})),!1;return!!_(e)||(t.append(C(n,r,s),c(e)),!1)}var l=[],p=Object.assign(B,{defaultVisitor:f,convertValue:c,isVisitable:_});if(!R.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!R.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),R.forEach(r,(function(r,o){!0===(!R.isUndefined(r)&&i.call(t,r,R.isString(o)?o.trim():o,n,p))&&e(r,n?n.concat(o):[o])})),l.pop()}}(e),t};function U(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,(function(e){return t[e]}))}function D(e,t){this._pairs=[],e&&P(e,this,t)}var F=D.prototype;F.append=function(e,t){this._pairs.push([e,t])},F.toString=function(e){var t=e?function(t){return e.call(this,t,U)}:U;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var L=D;function k(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var q=function(e,t,r){if(!t)return e;var n=e.indexOf("#");-1!==n&&(e=e.slice(0,n));var o=r&&r.encode||k,i=R.isURLSearchParams(t)?t.toString():new L(t,r).toString(o);return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e};function I(){this.handlers=[]}I.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},I.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},I.prototype.clear=function(){this.handlers&&(this.handlers=[])},I.prototype.forEach=function(e){R.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var M=I,H=function(e,t){R.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},J={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},V={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:L,FormData:FormData,Blob:Blob},protocols:["http","https","file","blob","url"]};var z=function(e){function t(e,r,n,o){var i=e[o++],s=Number.isFinite(+i),a=o>=e.length;return i=!i&&R.isArray(n)?n.length:i,a?(R.hasOwnProperty(n,i)?n[i]=[n[i],r]:n[i]=r,!s):(n[i]&&R.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&R.isArray(n[i])&&(n[i]=function(e){var t,r,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)n[r=o[t]]=e[r];return n}(n[i])),!s)}if(R.isFormData(e)&&R.isFunction(e.entries)){var r={};return R.forEachEntry(e,(function(e,n){t(function(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),n,r,0)})),r}return null},W=R.isStandardBrowserEnv()?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),R.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),R.isString(n)&&s.push("path="+n),R.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(){}},X=function(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t},K=["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"],$=R.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=R.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0};function Q(e,t,r){j.call(this,null==e?"canceled":e,j.ERR_CANCELED,t,r),this.name="CanceledError"}R.inherits(Q,j,{__CANCEL__:!0});var G=Q,Y=function(e){return new Promise((function(t,r){var n,o=e.data,i=e.headers,s=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}R.isFormData(o)&&R.isStandardBrowserEnv()&&delete i["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(c+":"+f)}var l=X(e.baseURL,e.url);function p(){if(u){var n,o,i,c,f,l="getAllResponseHeaders"in u?(n=u.getAllResponseHeaders(),f={},n?(R.forEach(n.split("\n"),(function(e){if(c=e.indexOf(":"),o=R.trim(e.slice(0,c)).toLowerCase(),i=R.trim(e.slice(c+1)),o){if(f[o]&&K.indexOf(o)>=0)return;f[o]="set-cookie"===o?(f[o]?f[o]:[]).concat([i]):f[o]?f[o]+", "+i:i}})),f):f):null;!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new j("Request failed with status code "+r.status,[j.ERR_BAD_REQUEST,j.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:s&&"text"!==s&&"json"!==s?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:l,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),q(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(new j("Request aborted",j.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new j("Network Error",j.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",n=e.transitional||J;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new j(t,n.clarifyTimeoutError?j.ETIMEDOUT:j.ECONNABORTED,e,u)),u=null},R.isStandardBrowserEnv()){var d=(e.withCredentials||$(l))&&e.xsrfCookieName?W.read(e.xsrfCookieName):void 0;d&&(i[e.xsrfHeaderName]=d)}"setRequestHeader"in u&&R.forEach(i,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete i[t]:u.setRequestHeader(t,e)})),R.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),s&&"json"!==s&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(t){u&&(r(!t||t.type?new G(null,e,req):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null);var h,m=(h=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&h[1]||"";m&&-1===V.protocols.indexOf(m)?r(new j("Unsupported protocol "+m+":",j.ERR_BAD_REQUEST,e)):u.send(o)}))},Z={"Content-Type":"application/x-www-form-urlencoded"};function ee(e,t){!R.isUndefined(e)&&R.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var te,re={transitional:J,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(te=Y),te),transformRequest:[function(e,t){H(t,"Accept"),H(t,"Content-Type");var r,n=t&&t["Content-Type"]||"",o=n.indexOf("application/json")>-1,i=R.isObject(e);if(i&&R.isHTMLForm(e)&&(e=new FormData(e)),R.isFormData(e))return o&&o?JSON.stringify(z(e)):e;if(R.isArrayBuffer(e)||R.isBuffer(e)||R.isStream(e)||R.isFile(e)||R.isBlob(e))return e;if(R.isArrayBufferView(e))return e.buffer;if(R.isURLSearchParams(e))return ee(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(i){if(-1!==n.indexOf("application/x-www-form-urlencoded"))return function(e,t){return P(e,new V.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return V.isNode&&R.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((r=R.isFileList(e))||n.indexOf("multipart/form-data")>-1){var s=this.env&&this.env.FormData;return P(r?{"files[]":e}:e,s&&new s,this.formSerializer)}}return i||o?(ee(t,"application/json"),function(e,t,r){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||re.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&R.isString(e)&&(r&&!this.responseType||n)){var o=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw j.from(e,j.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:V.classes.FormData,Blob:V.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};R.forEach(["delete","get","head"],(function(e){re.headers[e]={}})),R.forEach(["post","put","patch"],(function(e){re.headers[e]=R.merge(Z)}));var ne=re,oe=function(e,t,r,n){var o=this||ne;return R.forEach(n,(function(n){e=n.call(o,e,t,r)})),e},ie=function(e){return!(!e||!e.__CANCEL__)};function se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new G}var ae=function(e){return se(e),e.headers=e.headers||{},e.data=oe.call(e,e.data,e.headers,null,e.transformRequest),H(e.headers,"Accept"),H(e.headers,"Content-Type"),e.headers=R.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),R.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||ne.adapter)(e).then((function(t){return se(e),t.data=oe.call(e,t.data,t.headers,t.status,e.transformResponse),t}),(function(t){return ie(t)||(se(e),t&&t.response&&(t.response.data=oe.call(e,t.response.data,t.response.headers,t.response.status,e.transformResponse))),Promise.reject(t)}))},ue=function(e,t){t=t||{};var r={};function n(e,t){return R.isPlainObject(e)&&R.isPlainObject(t)?R.merge(e,t):R.isPlainObject(t)?R.merge({},t):R.isArray(t)?t.slice():t}function o(r){return R.isUndefined(t[r])?R.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function i(e){if(!R.isUndefined(t[e]))return n(void 0,t[e])}function s(r){return R.isUndefined(t[r])?R.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function a(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return R.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,n=t(e);R.isUndefined(n)&&t!==a||(r[e]=n)})),r},ce="1.0.0-alpha.1",fe=ce,le={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){le[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var pe={};le.transitional=function(e,t,r){function n(e,t){return"[Axios v"+fe+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,i){if(!1===e)throw new j(n(o," has been removed"+(t?" in "+t:"")),j.ERR_DEPRECATED);return t&&!pe[o]&&(pe[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var de={assertOptions:function(e,t,r){if("object"!=typeof e)throw new j("options must be an object",j.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new j("option "+i+" must be "+u,j.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new j("Unknown option "+i,j.ERR_BAD_OPTION)}},validators:le},he=de.validators;function me(e){this.defaults=e,this.interceptors={request:new M,response:new M}}me.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=ue(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&de.assertOptions(r,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!o){var a=[ae,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),i=Promise.resolve(t);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=t;n.length;){var c=n.shift(),f=n.shift();try{u=c(u)}catch(e){f(e);break}}try{i=ae(u)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},me.prototype.getUri=function(e){e=ue(this.defaults,e);var t=X(e.baseURL,e.url);return q(t,e.params,e.paramsSerializer)},R.forEach(["delete","get","head","options"],(function(e){me.prototype[e]=function(t,r){return this.request(ue(r||{},{method:e,url:t,data:(r||{}).data}))}})),R.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(ue(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}me.prototype[e]=t(),me.prototype[e+"Form"]=t(!0)}));var ye=me;function ve(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){for(var t=r._listeners.length;t-- >0;)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new G(e,n,o),t(r.reason))}))}ve.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ve.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},ve.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},ve.source=function(){var e;return{token:new ve((function(t){e=t})),cancel:e}};var Ee=ve;var be=function e(r){var n=new ye(r),o=t(ye.prototype.request,n);return R.extend(o,ye.prototype,n),R.extend(o,n),o.create=function(t){return e(ue(r,t))},o}(ne);be.Axios=ye,be.CanceledError=G,be.CancelToken=Ee,be.isCancel=ie,be.VERSION=ce,be.toFormData=P,be.AxiosError=j,be.Cancel=be.CanceledError,be.all=function(e){return Promise.all(e)},be.spread=function(e){return function(t){return e.apply(null,t)}},be.isAxiosError=function(e){return R.isObject(e)&&!0===e.isAxiosError},be.formToJSON=function(e){return z(R.isHTMLForm(e)?new FormData(e):e)};var ge=be,we=be;ge.default=we;export{ge as default}; | ||
function e(e,t){return function(){return e.apply(t,arguments)}}const{toString:t}=Object.prototype,{getPrototypeOf:n}=Object,r=(o=Object.create(null),e=>{const n=t.call(e);return o[n]||(o[n]=n.slice(8,-1).toLowerCase())});var o;const s=e=>(e=e.toLowerCase(),t=>r(t)===e),i=e=>t=>typeof t===e,{isArray:a}=Array,c=i("undefined");const u=s("ArrayBuffer");const l=i("string"),f=i("function"),h=i("number"),d=e=>null!==e&&"object"==typeof e,p=e=>{if("object"!==r(e))return!1;const t=n(e);return null===t||t===Object.prototype},m=s("Date"),g=s("File"),b=s("Blob"),y=s("FileList"),E=s("URLSearchParams");function w(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),a(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(r=0;r<s;r++)i=o[r],t.call(null,e[i],i,e)}}const O=(R="undefined"!=typeof Uint8Array&&n(Uint8Array),e=>R&&e instanceof R);var R;const S=s("HTMLFormElement"),A=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),j=s("RegExp"),T=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};w(n,((n,o)=>{!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},x={isArray:a,isArrayBuffer:u,isBuffer:function(e){return null!==e&&!c(e)&&null!==e.constructor&&!c(e.constructor)&&f(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{const n="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||t.call(e)===n||f(e.toString)&&e.toString()===n)},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&u(e.buffer),t},isString:l,isNumber:h,isBoolean:e=>!0===e||!1===e,isObject:d,isPlainObject:p,isUndefined:c,isDate:m,isFile:g,isBlob:b,isRegExp:j,isFunction:f,isStream:e=>d(e)&&f(e.pipe),isURLSearchParams:E,isTypedArray:O,isFileList:y,forEach:w,merge:function e(){const t={},n=(n,r)=>{p(t[r])&&p(n)?t[r]=e(t[r],n):p(n)?t[r]=e({},n):a(n)?t[r]=n.slice():t[r]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&w(arguments[e],n);return t},extend:(t,n,r,{allOwnKeys:o}={})=>(w(n,((n,o)=>{r&&f(n)?t[o]=e(n,r):t[o]=n}),{allOwnKeys:o}),t),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,r,o)=>{let s,i,a;const c={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],o&&!o(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==r&&n(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:r,kindOfTest:s,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(a(e))return e;let t=e.length;if(!h(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:S,hasOwnProperty:A,hasOwnProp:A,reduceDescriptors:T,freezeMethods:e=>{T(e,((t,n)=>{const r=e[n];f(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return a(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t)};function v(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}x.inherits(v,Error,{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,status:this.response&&this.response.status?this.response.status:null}}});const C=v.prototype,N={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{N[e]={value:e}})),Object.defineProperties(v,N),Object.defineProperty(C,"isAxiosError",{value:!0}),v.from=(e,t,n,r,o,s)=>{const i=Object.create(C);return x.toFlatObject(e,i,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),v.call(i,e.message,t,n,r,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};var _="object"==typeof self?self.FormData:window.FormData;function P(e){return x.isPlainObject(e)||x.isArray(e)}function B(e){return x.endsWith(e,"[]")?e.slice(0,-2):e}function D(e,t,n){return e?e.concat(t).map((function(e,t){return e=B(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const F=x.toFlatObject(x,{},null,(function(e){return/^is[A-Z]/.test(e)}));function U(e,t,n){if(!x.isObject(e))throw new TypeError("target must be an object");t=t||new(_||FormData);const r=(n=x.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!x.isUndefined(t[e])}))).metaTokens,o=n.visitor||l,s=n.dots,i=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&((c=t)&&x.isFunction(c.append)&&"FormData"===c[Symbol.toStringTag]&&c[Symbol.iterator]);var c;if(!x.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(x.isDate(e))return e.toISOString();if(!a&&x.isBlob(e))throw new v("Blob is not supported. Use a Buffer instead.");return x.isArrayBuffer(e)||x.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(x.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(x.isArray(e)&&function(e){return x.isArray(e)&&!e.some(P)}(e)||x.isFileList(e)||x.endsWith(n,"[]")&&(a=x.toArray(e)))return n=B(n),a.forEach((function(e,r){!x.isUndefined(e)&&t.append(!0===i?D([n],r,s):null===i?n:n+"[]",u(e))})),!1;return!!P(e)||(t.append(D(o,n,s),u(e)),!1)}const f=[],h=Object.assign(F,{defaultVisitor:l,convertValue:u,isVisitable:P});if(!x.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!x.isUndefined(n)){if(-1!==f.indexOf(n))throw Error("Circular reference detected in "+r.join("."));f.push(n),x.forEach(n,(function(n,s){!0===(!x.isUndefined(n)&&o.call(t,n,x.isString(s)?s.trim():s,r,h))&&e(n,r?r.concat(s):[s])})),f.pop()}}(e),t}function L(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function k(e,t){this._pairs=[],e&&U(e,this,t)}const q=k.prototype;function z(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function I(e,t,n){if(!t)return e;const r=e.indexOf("#");-1!==r&&(e=e.slice(0,r));const o=n&&n.encode||z,s=x.isURLSearchParams(t)?t.toString():new k(t,n).toString(o);return s&&(e+=(-1===e.indexOf("?")?"?":"&")+s),e}q.append=function(e,t){this._pairs.push([e,t])},q.toString=function(e){const t=e?function(t){return e.call(this,t,L)}:L;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class M{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){x.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}const J={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},H="undefined"!=typeof URLSearchParams?URLSearchParams:k,V=FormData,W=(()=>{let e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)})(),K={isBrowser:!0,classes:{URLSearchParams:H,FormData:V,Blob:Blob},isStandardBrowserEnv:W,protocols:["http","https","file","blob","url","data"]};function $(e){function t(e,n,r,o){let s=e[o++];const i=Number.isFinite(+s),a=o>=e.length;if(s=!s&&x.isArray(r)?r.length:s,a)return x.hasOwnProp(r,s)?r[s]=[r[s],n]:r[s]=n,!i;r[s]&&x.isObject(r[s])||(r[s]=[]);return t(e,n,r[s],o)&&x.isArray(r[s])&&(r[s]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}(r[s])),!i}if(x.isFormData(e)&&x.isFunction(e.entries)){const n={};return x.forEachEntry(e,((e,r)=>{t(function(e){return x.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const X=K.isStandardBrowserEnv?{write:function(e,t,n,r,o,s){const i=[];i.push(e+"="+encodeURIComponent(t)),x.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),x.isString(r)&&i.push("path="+r),x.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){const 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(){}};function Q(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const G=K.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=x.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0};function Y(e,t,n){v.call(this,null==e?"canceled":e,v.ERR_CANCELED,t,n),this.name="CanceledError"}x.inherits(Y,v,{__CANCEL__:!0});const Z=x.toObjectSet(["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"]),ee=Symbol("internals"),te=Symbol("defaults");function ne(e){return e&&String(e).trim().toLowerCase()}function re(e){return!1===e||null==e?e:String(e)}function oe(e,t,n,r){return x.isFunction(r)?r.call(this,t,n):x.isString(t)?x.isString(r)?-1!==t.indexOf(r):x.isRegExp(r)?r.test(t):void 0:void 0}function se(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}function ie(e,t){e&&this.set(e),this[te]=t||null}function ae(e,t){let n=0;const r=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,s=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),u=r[i];o||(o=c),n[s]=a,r[s]=c;let l=i,f=0;for(;l!==s;)f+=n[l++],l%=e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),c-o<t)return;const h=u&&c-u;return h?Math.round(1e3*f/h):void 0}}(50,250);return o=>{const s=o.loaded,i=o.lengthComputable?o.total:void 0,a=s-n,c=r(a);n=s;const u={loaded:s,total:i,progress:i?s/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&s<=i?(i-s)/c:void 0};u[t?"download":"upload"]=!0,e(u)}}function ce(e){return new Promise((function(t,n){let r=e.data;const o=ie.from(e.headers).normalize(),s=e.responseType;let i;function a(){e.cancelToken&&e.cancelToken.unsubscribe(i),e.signal&&e.signal.removeEventListener("abort",i)}x.isFormData(r)&&K.isStandardBrowserEnv&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+n))}const u=Q(e.baseURL,e.url);function l(){if(!c)return;const r=ie.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());!function(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new v("Request failed with status code "+n.status,[v.ERR_BAD_REQUEST,v.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),a()}),(function(e){n(e),a()}),{data:s&&"text"!==s&&"json"!==s?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:r,config:e,request:c}),c=null}if(c.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout,"onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(l)},c.onabort=function(){c&&(n(new v("Request aborted",v.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new v("Network Error",v.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||J;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new v(t,r.clarifyTimeoutError?v.ETIMEDOUT:v.ECONNABORTED,e,c)),c=null},K.isStandardBrowserEnv){const t=(e.withCredentials||G(u))&&e.xsrfCookieName&&X.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===r&&o.setContentType(null),"setRequestHeader"in c&&x.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),x.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&"json"!==s&&(c.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&c.addEventListener("progress",ae(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",ae(e.onUploadProgress)),(e.cancelToken||e.signal)&&(i=t=>{c&&(n(!t||t.type?new Y(null,e,c):t),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(i),e.signal&&(e.signal.aborted?i():e.signal.addEventListener("abort",i)));const f=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(u);f&&-1===K.protocols.indexOf(f)?n(new v("Unsupported protocol "+f+":",v.ERR_BAD_REQUEST,e)):c.send(r||null)}))}Object.assign(ie.prototype,{set:function(e,t,n){const r=this;function o(e,t,n){const o=ne(t);if(!o)throw new Error("header name must be a non-empty string");const s=se(r,o);(!s||!0===n||!1!==r[s]&&!1!==n)&&(e=x.isArray(e)?e.map(re):re(e),r[s||t]=e)}return x.isPlainObject(e)?x.forEach(e,((e,n)=>{o(e,n,t)})):o(t,e,n),this},get:function(e,t){if(!(e=ne(e)))return;const n=se(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(x.isFunction(t))return t.call(this,e,n);if(x.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}},has:function(e,t){if(e=ne(e)){const n=se(this,e);return!(!n||t&&!oe(0,this[n],n,t))}return!1},delete:function(e,t){const n=this;let r=!1;function o(e){if(e=ne(e)){const o=se(n,e);!o||t&&!oe(0,n[o],o,t)||(delete n[o],r=!0)}}return x.isArray(e)?e.forEach(o):o(e),r},clear:function(){return Object.keys(this).forEach(this.delete.bind(this))},normalize:function(e){const t=this,n={};return x.forEach(this,((r,o)=>{const s=se(n,o);if(s)return t[s]=re(r),void delete t[o];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();i!==o&&delete t[o],t[i]=re(r),n[i]=!0})),this},toJSON:function(){const e=Object.create(null);return x.forEach(Object.assign({},this[te]||null,this),((t,n)=>{null!=t&&!1!==t&&(e[n]=x.isArray(t)?t.join(", "):t)})),e}}),Object.assign(ie,{from:function(e){return x.isString(e)?new this((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Z[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e)):e instanceof this?e:new this(e)},accessor:function(e){const t=(this[ee]=this[ee]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=ne(e);t[r]||(!function(e,t){const n=x.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return x.isArray(e)?e.forEach(r):r(e),this}}),ie.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),x.freezeMethods(ie.prototype),x.freezeMethods(ie);const ue={http:ce,xhr:ce},le=e=>{if(x.isString(e)){const t=ue[e];if(!e)throw Error(x.hasOwnProp(e)?`Adapter '${e}' is not available in the build`:`Can not resolve adapter '${e}'`);return t}if(!x.isFunction(e))throw new TypeError("adapter is not a function");return e},fe={"Content-Type":"application/x-www-form-urlencoded"};const he={transitional:J,adapter:function(){let e;return"undefined"!=typeof XMLHttpRequest?e=le("xhr"):"undefined"!=typeof process&&"process"===x.kindOf(process)&&(e=le("http")),e}(),transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=x.isObject(e);o&&x.isHTMLForm(e)&&(e=new FormData(e));if(x.isFormData(e))return r&&r?JSON.stringify($(e)):e;if(x.isArrayBuffer(e)||x.isBuffer(e)||x.isStream(e)||x.isFile(e)||x.isBlob(e))return e;if(x.isArrayBufferView(e))return e.buffer;if(x.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return U(e,new K.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return K.isNode&&x.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=x.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return U(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(x.isString(e))try{return(t||JSON.parse)(e),x.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||he.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&x.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw v.from(e,v.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:K.classes.FormData,Blob:K.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};function de(e,t){const n=this||he,r=t||n,o=ie.from(r.headers);let s=r.data;return x.forEach(e,(function(e){s=e.call(n,s,o.normalize(),t?t.status:void 0)})),o.normalize(),s}function pe(e){return!(!e||!e.__CANCEL__)}function me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Y}function ge(e){me(e),e.headers=ie.from(e.headers),e.data=de.call(e,e.transformRequest);return(e.adapter||he.adapter)(e).then((function(t){return me(e),t.data=de.call(e,e.transformResponse,t),t.headers=ie.from(t.headers),t}),(function(t){return pe(t)||(me(e),t&&t.response&&(t.response.data=de.call(e,e.transformResponse,t.response),t.response.headers=ie.from(t.response.headers))),Promise.reject(t)}))}function be(e,t){t=t||{};const n={};function r(e,t){return x.isPlainObject(e)&&x.isPlainObject(t)?x.merge(e,t):x.isPlainObject(t)?x.merge({},t):x.isArray(t)?t.slice():t}function o(n){return x.isUndefined(t[n])?x.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function s(e){if(!x.isUndefined(t[e]))return r(void 0,t[e])}function i(n){return x.isUndefined(t[n])?x.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function a(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a};return x.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){const t=c[e]||o,r=t(e);x.isUndefined(r)&&t!==a||(n[e]=r)})),n}x.forEach(["delete","get","head"],(function(e){he.headers[e]={}})),x.forEach(["post","put","patch"],(function(e){he.headers[e]=x.merge(fe)}));const ye={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{ye[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const Ee={};ye.transitional=function(e,t,n){function r(e,t){return"[Axios v1.0.0] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,s)=>{if(!1===e)throw new v(r(o," has been removed"+(t?" in "+t:"")),v.ERR_DEPRECATED);return t&&!Ee[o]&&(Ee[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,s)}};const we={assertOptions:function(e,t,n){if("object"!=typeof e)throw new v("options must be an object",v.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const t=e[s],n=void 0===t||i(t,s,e);if(!0!==n)throw new v("option "+s+" must be "+n,v.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new v("Unknown option "+s,v.ERR_BAD_OPTION)}},validators:ye},Oe=we.validators;class Re{constructor(e){this.defaults=e,this.interceptors={request:new M,response:new M}}request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};const n=(t=be(this.defaults,t)).transitional;void 0!==n&&we.assertOptions(n,{silentJSONParsing:Oe.transitional(Oe.boolean),forcedJSONParsing:Oe.transitional(Oe.boolean),clarifyTimeoutError:Oe.transitional(Oe.boolean)},!1),t.method=(t.method||this.defaults.method||"get").toLowerCase();const r=t.headers&&x.merge(t.headers.common,t.headers[t.method]);r&&x.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),t.headers=new ie(t.headers,r);const o=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const i=[];let a;this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)}));let c,u=0;if(!s){const e=[ge.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,i),c=e.length,a=Promise.resolve(t);u<c;)a=a.then(e[u++],e[u++]);return a}c=o.length;let l=t;for(u=0;u<c;){const e=o[u++],t=o[u++];try{l=e(l)}catch(e){t.call(this,e);break}}try{a=ge.call(this,l)}catch(e){return Promise.reject(e)}for(u=0,c=i.length;u<c;)a=a.then(i[u++],i[u++]);return a}getUri(e){return I(Q((e=be(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}x.forEach(["delete","get","head","options"],(function(e){Re.prototype[e]=function(t,n){return this.request(be(n||{},{method:e,url:t,data:(n||{}).data}))}})),x.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(be(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Re.prototype[e]=t(),Re.prototype[e+"Form"]=t(!0)}));class Se{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new Y(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new Se((function(t){e=t})),cancel:e}}}const Ae=function t(n){const r=new Re(n),o=e(Re.prototype.request,r);return x.extend(o,Re.prototype,r,{allOwnKeys:!0}),x.extend(o,r,null,{allOwnKeys:!0}),o.create=function(e){return t(be(n,e))},o}(he);Ae.Axios=Re,Ae.CanceledError=Y,Ae.CancelToken=Se,Ae.isCancel=pe,Ae.VERSION="1.0.0",Ae.toFormData=U,Ae.AxiosError=v,Ae.Cancel=Ae.CanceledError,Ae.all=function(e){return Promise.all(e)},Ae.spread=function(e){return function(t){return e.apply(null,t)}},Ae.isAxiosError=function(e){return x.isObject(e)&&!0===e.isAxiosError},Ae.formToJSON=e=>$(x.isHTMLForm(e)?new FormData(e):e);export{Ae as default}; | ||
//# sourceMappingURL=axios.min.js.map |
269
index.d.ts
// TypeScript Version: 4.1 | ||
type AxiosHeaders = Record<string, string | string[] | number | boolean>; | ||
type AxiosHeaderValue = string | string[] | number | boolean | null; | ||
type RawAxiosHeaders = Record<string, AxiosHeaderValue>; | ||
@@ -12,14 +13,74 @@ type MethodsHeaders = { | ||
export type AxiosRequestHeaders = Partial<AxiosHeaders & MethodsHeaders & CommonHeaders>; | ||
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean; | ||
export type AxiosResponseHeaders = Record<string, string> & { | ||
type AxiosHeaderSetter = (value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher) => AxiosHeaders; | ||
type AxiosHeaderGetter = ((parser?: RegExp) => RegExpExecArray | null) | | ||
((matcher?: AxiosHeaderMatcher) => AxiosHeaderValue); | ||
type AxiosHeaderTester = (matcher?: AxiosHeaderMatcher) => boolean; | ||
export class AxiosHeaders { | ||
constructor( | ||
headers?: RawAxiosHeaders | AxiosHeaders, | ||
defaultHeaders?: RawAxiosHeaders | AxiosHeaders | ||
); | ||
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; | ||
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders; | ||
get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; | ||
has(header: string, matcher?: true | AxiosHeaderMatcher): boolean; | ||
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
clear(): boolean; | ||
normalize(format: boolean): AxiosHeaders; | ||
toJSON(): RawAxiosHeaders; | ||
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
static accessor(header: string | string[]): AxiosHeaders; | ||
setContentType: AxiosHeaderSetter; | ||
getContentType: AxiosHeaderGetter; | ||
hasContentType: AxiosHeaderTester; | ||
setContentLength: AxiosHeaderSetter; | ||
getContentLength: AxiosHeaderGetter; | ||
hasContentLength: AxiosHeaderTester; | ||
setAccept: AxiosHeaderSetter; | ||
getAccept: AxiosHeaderGetter; | ||
hasAccept: AxiosHeaderTester; | ||
setUserAgent: AxiosHeaderSetter; | ||
getUserAgent: AxiosHeaderGetter; | ||
hasUserAgent: AxiosHeaderTester; | ||
setContentEncoding: AxiosHeaderSetter; | ||
getContentEncoding: AxiosHeaderGetter; | ||
hasContentEncoding: AxiosHeaderTester; | ||
} | ||
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>; | ||
export type AxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders> & AxiosHeaders; | ||
export type RawAxiosResponseHeaders = Partial<Record<string, string> & { | ||
"set-cookie"?: string[] | ||
}; | ||
}>; | ||
export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders; | ||
export interface AxiosRequestTransformer { | ||
(data: any, headers: AxiosRequestHeaders): any; | ||
(this: AxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any; | ||
} | ||
export interface AxiosResponseTransformer { | ||
(data: any, headers?: AxiosResponseHeaders, status?: number): any; | ||
(this: AxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any; | ||
} | ||
@@ -46,35 +107,101 @@ | ||
export enum HttpStatusCode { | ||
Continue = 100, | ||
SwitchingProtocols = 101, | ||
Processing = 102, | ||
EarlyHints = 103, | ||
Ok = 200, | ||
Created = 201, | ||
Accepted = 202, | ||
NonAuthoritativeInformation = 203, | ||
NoContent = 204, | ||
ResetContent = 205, | ||
PartialContent = 206, | ||
MultiStatus = 207, | ||
AlreadyReported = 208, | ||
ImUsed = 226, | ||
MultipleChoices = 300, | ||
MovedPermanently = 301, | ||
Found = 302, | ||
SeeOther = 303, | ||
NotModified = 304, | ||
UseProxy = 305, | ||
Unused = 306, | ||
TemporaryRedirect = 307, | ||
PermanentRedirect = 308, | ||
BadRequest = 400, | ||
Unauthorized = 401, | ||
PaymentRequired = 402, | ||
Forbidden = 403, | ||
NotFound = 404, | ||
MethodNotAllowed = 405, | ||
NotAcceptable = 406, | ||
ProxyAuthenticationRequired = 407, | ||
RequestTimeout = 408, | ||
Conflict = 409, | ||
Gone = 410, | ||
LengthRequired = 411, | ||
PreconditionFailed = 412, | ||
PayloadTooLarge = 413, | ||
UriTooLong = 414, | ||
UnsupportedMediaType = 415, | ||
RangeNotSatisfiable = 416, | ||
ExpectationFailed = 417, | ||
ImATeapot = 418, | ||
MisdirectedRequest = 421, | ||
UnprocessableEntity = 422, | ||
Locked = 423, | ||
FailedDependency = 424, | ||
TooEarly = 425, | ||
UpgradeRequired = 426, | ||
PreconditionRequired = 428, | ||
TooManyRequests = 429, | ||
RequestHeaderFieldsTooLarge = 431, | ||
UnavailableForLegalReasons = 451, | ||
InternalServerError = 500, | ||
NotImplemented = 501, | ||
BadGateway = 502, | ||
ServiceUnavailable = 503, | ||
GatewayTimeout = 504, | ||
HttpVersionNotSupported = 505, | ||
VariantAlsoNegotiates = 506, | ||
InsufficientStorage = 507, | ||
LoopDetected = 508, | ||
NotExtended = 510, | ||
NetworkAuthenticationRequired = 511, | ||
} | ||
export type Method = | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK'; | ||
| 'get' | 'GET' | ||
| 'delete' | 'DELETE' | ||
| 'head' | 'HEAD' | ||
| 'options' | 'OPTIONS' | ||
| 'post' | 'POST' | ||
| 'put' | 'PUT' | ||
| 'patch' | 'PATCH' | ||
| 'purge' | 'PURGE' | ||
| 'link' | 'LINK' | ||
| 'unlink' | 'UNLINK'; | ||
export type ResponseType = | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
| 'arraybuffer' | ||
| 'blob' | ||
| 'document' | ||
| 'json' | ||
| 'text' | ||
| 'stream'; | ||
export type responseEncoding = | ||
| 'ascii' | 'ASCII' | ||
| 'ansi' | 'ANSI' | ||
| 'binary' | 'BINARY' | ||
| 'base64' | 'BASE64' | ||
| 'base64url' | 'BASE64URL' | ||
| 'hex' | 'HEX' | ||
| 'latin1' | 'LATIN1' | ||
| 'ucs-2' | 'UCS-2' | ||
| 'ucs2' | 'UCS2' | ||
| 'utf-8' | 'UTF-8' | ||
| 'utf8' | 'UTF8' | ||
| 'utf16le' | 'UTF16LE'; | ||
export type responseEncoding = | ||
| 'ascii' | 'ASCII' | ||
| 'ansi' | 'ANSI' | ||
| 'binary' | 'BINARY' | ||
| 'base64' | 'BASE64' | ||
| 'base64url' | 'BASE64URL' | ||
| 'hex' | 'HEX' | ||
| 'latin1' | 'LATIN1' | ||
| 'ucs-2' | 'UCS-2' | ||
| 'ucs2' | 'UCS2' | ||
| 'utf-8' | 'UTF-8' | ||
| 'utf8' | 'UTF8' | ||
| 'utf16le' | 'UTF16LE'; | ||
@@ -114,3 +241,3 @@ export interface TransitionalOptions { | ||
metaTokens?: boolean; | ||
indexes?: boolean; | ||
indexes?: boolean | null; | ||
} | ||
@@ -130,2 +257,19 @@ | ||
type MaxUploadRate = number; | ||
type MaxDownloadRate = number; | ||
export interface AxiosProgressEvent { | ||
loaded: number; | ||
total?: number; | ||
progress?: number; | ||
bytes: number; | ||
rate?: number; | ||
estimated?: number; | ||
upload?: boolean; | ||
download?: boolean; | ||
} | ||
type Milliseconds = number; | ||
export interface AxiosRequestConfig<D = any> { | ||
@@ -137,7 +281,7 @@ url?: string; | ||
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; | ||
headers?: AxiosRequestHeaders; | ||
headers?: RawAxiosRequestHeaders; | ||
params?: any; | ||
paramsSerializer?: ParamsSerializerOptions; | ||
data?: D; | ||
timeout?: number; | ||
timeout?: Milliseconds; | ||
timeoutErrorMessage?: string; | ||
@@ -151,4 +295,4 @@ withCredentials?: boolean; | ||
xsrfHeaderName?: string; | ||
onUploadProgress?: (progressEvent: ProgressEvent) => void; | ||
onDownloadProgress?: (progressEvent: ProgressEvent) => void; | ||
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void; | ||
maxContentLength?: number; | ||
@@ -158,2 +302,3 @@ validateStatus?: ((status: number) => boolean) | null; | ||
maxRedirects?: number; | ||
maxRate?: number | [MaxUploadRate, MaxDownloadRate]; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void; | ||
@@ -176,13 +321,13 @@ socketPath?: string | null; | ||
export interface HeadersDefaults { | ||
common: AxiosRequestHeaders; | ||
delete: AxiosRequestHeaders; | ||
get: AxiosRequestHeaders; | ||
head: AxiosRequestHeaders; | ||
post: AxiosRequestHeaders; | ||
put: AxiosRequestHeaders; | ||
patch: AxiosRequestHeaders; | ||
options?: AxiosRequestHeaders; | ||
purge?: AxiosRequestHeaders; | ||
link?: AxiosRequestHeaders; | ||
unlink?: AxiosRequestHeaders; | ||
common: RawAxiosRequestHeaders; | ||
delete: RawAxiosRequestHeaders; | ||
get: RawAxiosRequestHeaders; | ||
head: RawAxiosRequestHeaders; | ||
post: RawAxiosRequestHeaders; | ||
put: RawAxiosRequestHeaders; | ||
patch: RawAxiosRequestHeaders; | ||
options?: RawAxiosRequestHeaders; | ||
purge?: RawAxiosRequestHeaders; | ||
link?: RawAxiosRequestHeaders; | ||
unlink?: RawAxiosRequestHeaders; | ||
} | ||
@@ -195,3 +340,3 @@ | ||
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> { | ||
headers?: AxiosRequestHeaders | Partial<HeadersDefaults>; | ||
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>; | ||
} | ||
@@ -203,3 +348,3 @@ | ||
statusText: string; | ||
headers: AxiosResponseHeaders; | ||
headers: RawAxiosResponseHeaders | AxiosResponseHeaders; | ||
config: AxiosRequestConfig<D>; | ||
@@ -211,7 +356,7 @@ request?: any; | ||
constructor( | ||
message?: string, | ||
code?: string, | ||
config?: AxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
message?: string, | ||
code?: string, | ||
config?: AxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
); | ||
@@ -280,3 +425,3 @@ | ||
export interface AxiosInterceptorManager<V> { | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; | ||
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; | ||
eject(id: number): void; | ||
@@ -307,8 +452,8 @@ } | ||
export interface AxiosInstance extends Axios { | ||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): AxiosPromise<R>; | ||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): AxiosPromise<R>; | ||
<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>; | ||
<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>; | ||
defaults: Omit<AxiosDefaults, 'headers'> & { | ||
headers: HeadersDefaults & { | ||
[key: string]: string | number | boolean | undefined | ||
[key: string]: AxiosHeaderValue | ||
} | ||
@@ -315,0 +460,0 @@ }; |
@@ -1,1 +0,2 @@ | ||
module.exports = require('./lib/axios'); | ||
import axios from './lib/axios.js'; | ||
export default axios; |
'use strict'; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var getProxyForUrl = require('proxy-from-env').getProxyForUrl; | ||
var http = require('http'); | ||
var https = require('https'); | ||
var httpFollow = require('follow-redirects/http'); | ||
var httpsFollow = require('follow-redirects/https'); | ||
var url = require('url'); | ||
var zlib = require('zlib'); | ||
var VERSION = require('./../env/data').version; | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
var platform = require('../platform'); | ||
var fromDataURI = require('../helpers/fromDataURI'); | ||
var stream = require('stream'); | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import {getProxyForUrl} from 'proxy-from-env'; | ||
import http from 'http'; | ||
import https from 'https'; | ||
import followRedirects from 'follow-redirects'; | ||
import zlib from 'zlib'; | ||
import {VERSION} from '../env/data.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import platform from '../platform/index.js'; | ||
import fromDataURI from '../helpers/fromDataURI.js'; | ||
import stream from 'stream'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import AxiosTransformStream from '../helpers/AxiosTransformStream.js'; | ||
import EventEmitter from 'events'; | ||
var isHttps = /https:?/; | ||
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress); | ||
var supportedProtocols = platform.protocols.map(function(protocol) { | ||
const {http: httpFollow, https: httpsFollow} = followRedirects; | ||
const isHttps = /https:?/; | ||
const supportedProtocols = platform.protocols.map(protocol => { | ||
return protocol + ':'; | ||
}); | ||
/** | ||
* If the proxy or config beforeRedirects functions are defined, call them with the options | ||
* object. | ||
* | ||
* @param {Object<string, any>} options - The options object that was passed to the request. | ||
* | ||
* @returns {Object<string, any>} | ||
*/ | ||
function dispatchBeforeRedirect(options) { | ||
@@ -38,2 +51,3 @@ if (options.beforeRedirects.proxy) { | ||
/** | ||
* If the proxy or config afterRedirects functions are defined, call them with the options | ||
* | ||
@@ -43,11 +57,11 @@ * @param {http.ClientRequestArgs} options | ||
* @param {string} location | ||
* | ||
* @returns {http.ClientRequestArgs} | ||
*/ | ||
function setProxy(options, configProxy, location) { | ||
var proxy = configProxy; | ||
let proxy = configProxy; | ||
if (!proxy && proxy !== false) { | ||
var proxyUrl = getProxyForUrl(location); | ||
const proxyUrl = getProxyForUrl(location); | ||
if (proxyUrl) { | ||
proxy = url.parse(proxyUrl); | ||
// replace 'host' since the proxy object is not a URL object | ||
proxy.host = proxy.hostname; | ||
proxy = new URL(proxyUrl); | ||
} | ||
@@ -57,2 +71,6 @@ } | ||
// Basic proxy authorization | ||
if (proxy.username) { | ||
proxy.auth = (proxy.username || '') + ':' + (proxy.password || ''); | ||
} | ||
if (proxy.auth) { | ||
@@ -63,3 +81,3 @@ // Support proxy auth object form | ||
} | ||
var base64 = Buffer | ||
const base64 = Buffer | ||
.from(proxy.auth, 'utf8') | ||
@@ -71,4 +89,5 @@ .toString('base64'); | ||
options.headers.host = options.hostname + (options.port ? ':' + options.port : ''); | ||
options.hostname = proxy.host; | ||
options.host = proxy.host; | ||
options.hostname = proxy.hostname; | ||
// Replace 'host' since options is not a URL object | ||
options.host = proxy.hostname; | ||
options.port = proxy.port; | ||
@@ -89,36 +108,72 @@ options.path = location; | ||
/*eslint consistent-return:0*/ | ||
module.exports = function httpAdapter(config) { | ||
export default function httpAdapter(config) { | ||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { | ||
var onCanceled; | ||
function done() { | ||
let data = config.data; | ||
const responseType = config.responseType; | ||
const responseEncoding = config.responseEncoding; | ||
const method = config.method.toUpperCase(); | ||
let isFinished; | ||
let isDone; | ||
let rejected = false; | ||
let req; | ||
// temporary internal emitter until the AxiosRequest class will be implemented | ||
const emitter = new EventEmitter(); | ||
function onFinished() { | ||
if (isFinished) return; | ||
isFinished = true; | ||
if (config.cancelToken) { | ||
config.cancelToken.unsubscribe(onCanceled); | ||
config.cancelToken.unsubscribe(abort); | ||
} | ||
if (config.signal) { | ||
config.signal.removeEventListener('abort', onCanceled); | ||
config.signal.removeEventListener('abort', abort); | ||
} | ||
emitter.removeAllListeners(); | ||
} | ||
var resolve = function resolve(value) { | ||
done(); | ||
resolvePromise(value); | ||
function done(value, isRejected) { | ||
if (isDone) return; | ||
isDone = true; | ||
if (isRejected) { | ||
rejected = true; | ||
onFinished(); | ||
} | ||
isRejected ? rejectPromise(value) : resolvePromise(value); | ||
} | ||
const resolve = function resolve(value) { | ||
done(value); | ||
}; | ||
var rejected = false; | ||
var reject = function reject(value) { | ||
done(); | ||
rejected = true; | ||
rejectPromise(value); | ||
const reject = function reject(value) { | ||
done(value, true); | ||
}; | ||
var data = config.data; | ||
var responseType = config.responseType; | ||
var responseEncoding = config.responseEncoding; | ||
var method = config.method.toUpperCase(); | ||
function abort(reason) { | ||
emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason); | ||
} | ||
emitter.once('abort', reject); | ||
if (config.cancelToken || config.signal) { | ||
config.cancelToken && config.cancelToken.subscribe(abort); | ||
if (config.signal) { | ||
config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort); | ||
} | ||
} | ||
// Parse url | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
var parsed = url.parse(fullPath); | ||
var protocol = parsed.protocol || supportedProtocols[0]; | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
const parsed = new URL(fullPath); | ||
const protocol = parsed.protocol || supportedProtocols[0]; | ||
if (protocol === 'data:') { | ||
var convertedData; | ||
let convertedData; | ||
@@ -130,3 +185,3 @@ if (method !== 'GET') { | ||
headers: {}, | ||
config: config | ||
config | ||
}); | ||
@@ -158,3 +213,3 @@ } | ||
headers: {}, | ||
config: config | ||
config | ||
}); | ||
@@ -171,25 +226,19 @@ } | ||
var headers = config.headers; | ||
var headerNames = {}; | ||
const headers = AxiosHeaders.from(config.headers).normalize(); | ||
Object.keys(headers).forEach(function storeLowerName(name) { | ||
headerNames[name.toLowerCase()] = name; | ||
}); | ||
// Set User-Agent (required by some servers) | ||
// See https://github.com/axios/axios/issues/69 | ||
if ('user-agent' in headerNames) { | ||
// User-Agent is specified; handle case where no UA header is desired | ||
if (!headers[headerNames['user-agent']]) { | ||
delete headers[headerNames['user-agent']]; | ||
} | ||
// Otherwise, use specified value | ||
} else { | ||
// Only set header if it hasn't been set in config | ||
headers['User-Agent'] = 'axios/' + VERSION; | ||
} | ||
// User-Agent is specified; handle case where no UA header is desired | ||
// Only set header if it hasn't been set in config | ||
headers.set('User-Agent', 'axios/' + VERSION, false); | ||
const onDownloadProgress = config.onDownloadProgress; | ||
const onUploadProgress = config.onUploadProgress; | ||
const maxRate = config.maxRate; | ||
let maxUploadRate = undefined; | ||
let maxDownloadRate = undefined; | ||
// support for https://www.npmjs.com/package/form-data api | ||
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { | ||
Object.assign(headers, data.getHeaders()); | ||
headers.set(data.getHeaders()); | ||
} else if (data && !utils.isStream(data)) { | ||
@@ -210,2 +259,5 @@ if (Buffer.isBuffer(data)) { | ||
// Add Content-Length header if data exists | ||
headers.set('Content-Length', data.length, false); | ||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) { | ||
@@ -218,45 +270,66 @@ return reject(new AxiosError( | ||
} | ||
} | ||
// Add Content-Length header if data exists | ||
if (!headerNames['content-length']) { | ||
headers['Content-Length'] = data.length; | ||
const contentLength = +headers.getContentLength(); | ||
if (utils.isArray(maxRate)) { | ||
maxUploadRate = maxRate[0]; | ||
maxDownloadRate = maxRate[1]; | ||
} else { | ||
maxUploadRate = maxDownloadRate = maxRate; | ||
} | ||
if (data && (onUploadProgress || maxUploadRate)) { | ||
if (!utils.isStream(data)) { | ||
data = stream.Readable.from(data, {objectMode: false}); | ||
} | ||
data = stream.pipeline([data, new AxiosTransformStream({ | ||
length: utils.toFiniteNumber(contentLength), | ||
maxRate: utils.toFiniteNumber(maxUploadRate) | ||
})], utils.noop); | ||
onUploadProgress && data.on('progress', progress => { | ||
onUploadProgress(Object.assign(progress, { | ||
upload: true | ||
})); | ||
}); | ||
} | ||
// HTTP basic authentication | ||
var auth = undefined; | ||
let auth = undefined; | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password || ''; | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password || ''; | ||
auth = username + ':' + password; | ||
} | ||
if (!auth && parsed.auth) { | ||
var urlAuth = parsed.auth.split(':'); | ||
var urlUsername = urlAuth[0] || ''; | ||
var urlPassword = urlAuth[1] || ''; | ||
if (!auth && parsed.username) { | ||
const urlUsername = parsed.username; | ||
const urlPassword = parsed.password; | ||
auth = urlUsername + ':' + urlPassword; | ||
} | ||
if (auth && headerNames.authorization) { | ||
delete headers[headerNames.authorization]; | ||
} | ||
auth && headers.delete('authorization'); | ||
const path = parsed.pathname.concat(parsed.searchParams); | ||
try { | ||
buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
buildURL(path, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
} catch (err) { | ||
var customErr = new Error(err.message); | ||
const customErr = new Error(err.message); | ||
customErr.config = config; | ||
customErr.url = config.url; | ||
customErr.exists = true; | ||
reject(customErr); | ||
return reject(customErr); | ||
} | ||
var options = { | ||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), | ||
headers.set('Accept-Encoding', 'gzip, deflate, br', false); | ||
const options = { | ||
path: buildURL(path, config.params, config.paramsSerializer).replace(/^\?/, ''), | ||
method: method, | ||
headers: headers, | ||
headers: headers.toJSON(), | ||
agents: { http: config.httpAgent, https: config.httpsAgent }, | ||
auth: auth, | ||
protocol: protocol, | ||
auth, | ||
protocol, | ||
beforeRedirect: dispatchBeforeRedirect, | ||
@@ -274,4 +347,4 @@ beforeRedirects: {} | ||
var transport; | ||
var isHttpsRequest = isHttps.test(options.protocol); | ||
let transport; | ||
const isHttpsRequest = isHttps.test(options.protocol); | ||
options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; | ||
@@ -304,10 +377,12 @@ if (config.transport) { | ||
// Create the request | ||
var req = transport.request(options, function handleResponse(res) { | ||
if (req.aborted) return; | ||
req = transport.request(options, function handleResponse(res) { | ||
if (req.destroyed) return; | ||
const streams = [res]; | ||
// uncompress the response body transparently if required | ||
var responseStream = res; | ||
let responseStream = res; | ||
// return the last request in case of redirects | ||
var lastRequest = res.req || req; | ||
const lastRequest = res.req || req; | ||
@@ -328,3 +403,3 @@ // if decompress disabled we should not decompress | ||
// add the unzipper to the body stream processing pipeline | ||
responseStream = responseStream.pipe(zlib.createUnzip()); | ||
streams.push(zlib.createUnzip()); | ||
@@ -334,10 +409,39 @@ // remove the content-encoding in order to not confuse downstream operations | ||
break; | ||
case 'br': | ||
if (isBrotliSupported) { | ||
streams.push(zlib.createBrotliDecompress()); | ||
delete res.headers['content-encoding']; | ||
} | ||
} | ||
} | ||
var response = { | ||
if (onDownloadProgress) { | ||
const responseLength = +res.headers['content-length']; | ||
const transformStream = new AxiosTransformStream({ | ||
length: utils.toFiniteNumber(responseLength), | ||
maxRate: utils.toFiniteNumber(maxDownloadRate) | ||
}); | ||
onDownloadProgress && transformStream.on('progress', progress => { | ||
onDownloadProgress(Object.assign(progress, { | ||
download: true | ||
})); | ||
}); | ||
streams.push(transformStream); | ||
} | ||
responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0]; | ||
const offListeners = stream.finished(responseStream, () => { | ||
offListeners(); | ||
onFinished(); | ||
}); | ||
const response = { | ||
status: res.statusCode, | ||
statusText: res.statusMessage, | ||
headers: res.headers, | ||
config: config, | ||
headers: new AxiosHeaders(res.headers), | ||
config, | ||
request: lastRequest | ||
@@ -350,4 +454,5 @@ }; | ||
} else { | ||
var responseBuffer = []; | ||
var totalResponseBytes = 0; | ||
const responseBuffer = []; | ||
let totalResponseBytes = 0; | ||
responseStream.on('data', function handleStreamData(chunk) { | ||
@@ -371,4 +476,4 @@ responseBuffer.push(chunk); | ||
} | ||
responseStream.destroy(); | ||
reject(new AxiosError( | ||
const err = new AxiosError( | ||
'maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
@@ -378,7 +483,9 @@ AxiosError.ERR_BAD_RESPONSE, | ||
lastRequest | ||
)); | ||
); | ||
responseStream.destroy(err); | ||
reject(err); | ||
}); | ||
responseStream.on('error', function handleStreamError(err) { | ||
if (req.aborted) return; | ||
if (req.destroyed) return; | ||
reject(AxiosError.from(err, null, config, lastRequest)); | ||
@@ -389,3 +496,3 @@ }); | ||
try { | ||
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer); | ||
let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer); | ||
if (responseType !== 'arraybuffer') { | ||
@@ -404,4 +511,16 @@ responseData = responseData.toString(responseEncoding); | ||
} | ||
emitter.once('abort', err => { | ||
if (!responseStream.destroyed) { | ||
responseStream.emit('error', err); | ||
responseStream.destroy(); | ||
} | ||
}); | ||
}); | ||
emitter.once('abort', err => { | ||
reject(err); | ||
req.destroy(err); | ||
}); | ||
// Handle errors | ||
@@ -423,3 +542,3 @@ req.on('error', function handleRequestError(err) { | ||
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types. | ||
var timeout = parseInt(config.timeout, 10); | ||
const timeout = parseInt(config.timeout, 10); | ||
@@ -443,5 +562,5 @@ if (isNaN(timeout)) { | ||
req.setTimeout(timeout, function handleRequestTimeout() { | ||
req.abort(); | ||
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
var transitional = config.transitional || transitionalDefaults; | ||
if (isDone) return; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
@@ -456,27 +575,28 @@ timeoutErrorMessage = config.timeoutErrorMessage; | ||
)); | ||
abort(); | ||
}); | ||
} | ||
if (config.cancelToken || config.signal) { | ||
// Handle cancellation | ||
// eslint-disable-next-line func-names | ||
onCanceled = function(cancel) { | ||
if (req.aborted) return; | ||
req.abort(); | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, req) : cancel); | ||
}; | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
let ended = false; | ||
let errored = false; | ||
config.cancelToken && config.cancelToken.subscribe(onCanceled); | ||
if (config.signal) { | ||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); | ||
} | ||
} | ||
data.on('end', () => { | ||
ended = true; | ||
}); | ||
data.once('error', err => { | ||
errored = true; | ||
req.destroy(err); | ||
}); | ||
// Send the request | ||
if (utils.isStream(data)) { | ||
data.on('error', function handleStreamError(err) { | ||
reject(AxiosError.from(err, config, null, req)); | ||
}).pipe(req); | ||
data.on('close', () => { | ||
if (!ended && !errored) { | ||
abort(new CanceledError('Request stream has been aborted', config, req)); | ||
} | ||
}); | ||
data.pipe(req); | ||
} else { | ||
@@ -486,2 +606,2 @@ req.end(data); | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var settle = require('./../core/settle'); | ||
var cookies = require('./../helpers/cookies'); | ||
var buildURL = require('./../helpers/buildURL'); | ||
var buildFullPath = require('../core/buildFullPath'); | ||
var parseHeaders = require('./../helpers/parseHeaders'); | ||
var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
var parseProtocol = require('../helpers/parseProtocol'); | ||
var platform = require('../platform'); | ||
import utils from './../utils.js'; | ||
import settle from './../core/settle.js'; | ||
import cookies from './../helpers/cookies.js'; | ||
import buildURL from './../helpers/buildURL.js'; | ||
import buildFullPath from '../core/buildFullPath.js'; | ||
import isURLSameOrigin from './../helpers/isURLSameOrigin.js'; | ||
import transitionalDefaults from '../defaults/transitional.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import parseProtocol from '../helpers/parseProtocol.js'; | ||
import platform from '../platform/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
import speedometer from '../helpers/speedometer.js'; | ||
module.exports = function xhrAdapter(config) { | ||
function progressEventReducer(listener, isDownloadStream) { | ||
let bytesNotified = 0; | ||
const _speedometer = speedometer(50, 250); | ||
return e => { | ||
const loaded = e.loaded; | ||
const total = e.lengthComputable ? e.total : undefined; | ||
const progressBytes = loaded - bytesNotified; | ||
const rate = _speedometer(progressBytes); | ||
const inRange = loaded <= total; | ||
bytesNotified = loaded; | ||
const data = { | ||
loaded, | ||
total, | ||
progress: total ? (loaded / total) : undefined, | ||
bytes: progressBytes, | ||
rate: rate ? rate : undefined, | ||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined | ||
}; | ||
data[isDownloadStream ? 'download' : 'upload'] = true; | ||
listener(data); | ||
}; | ||
} | ||
export default function xhrAdapter(config) { | ||
return new Promise(function dispatchXhrRequest(resolve, reject) { | ||
var requestData = config.data; | ||
var requestHeaders = config.headers; | ||
var responseType = config.responseType; | ||
var onCanceled; | ||
let requestData = config.data; | ||
const requestHeaders = AxiosHeaders.from(config.headers).normalize(); | ||
const responseType = config.responseType; | ||
let onCanceled; | ||
function done() { | ||
@@ -32,16 +61,16 @@ if (config.cancelToken) { | ||
if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) { | ||
delete requestHeaders['Content-Type']; // Let the browser set it | ||
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) { | ||
requestHeaders.setContentType(false); // Let the browser set it | ||
} | ||
var request = new XMLHttpRequest(); | ||
let request = new XMLHttpRequest(); | ||
// HTTP basic authentication | ||
if (config.auth) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); | ||
const username = config.auth.username || ''; | ||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password)); | ||
} | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
@@ -58,6 +87,8 @@ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
// Prepare the response | ||
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; | ||
var responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
const responseHeaders = AxiosHeaders.from( | ||
'getAllResponseHeaders' in request && request.getAllResponseHeaders() | ||
); | ||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ? | ||
request.responseText : request.response; | ||
var response = { | ||
const response = { | ||
data: responseData, | ||
@@ -67,4 +98,4 @@ status: request.status, | ||
headers: responseHeaders, | ||
config: config, | ||
request: request | ||
config, | ||
request | ||
}; | ||
@@ -131,4 +162,4 @@ | ||
request.ontimeout = function handleTimeout() { | ||
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
var transitional = config.transitional || transitionalDefaults; | ||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; | ||
const transitional = config.transitional || transitionalDefaults; | ||
if (config.timeoutErrorMessage) { | ||
@@ -150,23 +181,19 @@ timeoutErrorMessage = config.timeoutErrorMessage; | ||
// Specifically not if we're in a web worker, or react-native. | ||
if (utils.isStandardBrowserEnv()) { | ||
if (platform.isStandardBrowserEnv) { | ||
// Add xsrf header | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) | ||
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName); | ||
if (xsrfValue) { | ||
requestHeaders[config.xsrfHeaderName] = xsrfValue; | ||
requestHeaders.set(config.xsrfHeaderName, xsrfValue); | ||
} | ||
} | ||
// Remove Content-Type if data is undefined | ||
requestData === undefined && requestHeaders.setContentType(null); | ||
// Add headers to the request | ||
if ('setRequestHeader' in request) { | ||
utils.forEach(requestHeaders, function setRequestHeader(val, key) { | ||
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { | ||
// Remove Content-Type if data is undefined | ||
delete requestHeaders[key]; | ||
} else { | ||
// Otherwise add header to the request | ||
request.setRequestHeader(key, val); | ||
} | ||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) { | ||
request.setRequestHeader(key, val); | ||
}); | ||
@@ -187,3 +214,3 @@ } | ||
if (typeof config.onDownloadProgress === 'function') { | ||
request.addEventListener('progress', config.onDownloadProgress); | ||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true)); | ||
} | ||
@@ -193,3 +220,3 @@ | ||
if (typeof config.onUploadProgress === 'function' && request.upload) { | ||
request.upload.addEventListener('progress', config.onUploadProgress); | ||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress)); | ||
} | ||
@@ -200,7 +227,7 @@ | ||
// eslint-disable-next-line func-names | ||
onCanceled = function(cancel) { | ||
onCanceled = cancel => { | ||
if (!request) { | ||
return; | ||
} | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, req) : cancel); | ||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel); | ||
request.abort(); | ||
@@ -216,8 +243,4 @@ request = null; | ||
if (!requestData) { | ||
requestData = null; | ||
} | ||
const protocol = parseProtocol(fullPath); | ||
var protocol = parseProtocol(fullPath); | ||
if (protocol && platform.protocols.indexOf(protocol) === -1) { | ||
@@ -230,4 +253,4 @@ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config)); | ||
// Send the request | ||
request.send(requestData); | ||
request.send(requestData || null); | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./utils'); | ||
var bind = require('./helpers/bind'); | ||
var Axios = require('./core/Axios'); | ||
var mergeConfig = require('./core/mergeConfig'); | ||
var defaults = require('./defaults'); | ||
var formDataToJSON = require('./helpers/formDataToJSON'); | ||
import utils from './utils.js'; | ||
import bind from './helpers/bind.js'; | ||
import Axios from './core/Axios.js'; | ||
import mergeConfig from './core/mergeConfig.js'; | ||
import defaults from './defaults/index.js'; | ||
import formDataToJSON from './helpers/formDataToJSON.js'; | ||
import CanceledError from './cancel/CanceledError.js'; | ||
import CancelToken from'./cancel/CancelToken.js'; | ||
import isCancel from'./cancel/isCancel.js'; | ||
import {VERSION} from './env/data.js'; | ||
import toFormData from './helpers/toFormData.js'; | ||
import AxiosError from './core/AxiosError.js'; | ||
import spread from './helpers/spread.js'; | ||
import isAxiosError from './helpers/isAxiosError.js'; | ||
/** | ||
@@ -13,13 +22,14 @@ * Create an instance of Axios | ||
* @param {Object} defaultConfig The default config for the instance | ||
* @return {Axios} A new instance of Axios | ||
* | ||
* @returns {Axios} A new instance of Axios | ||
*/ | ||
function createInstance(defaultConfig) { | ||
var context = new Axios(defaultConfig); | ||
var instance = bind(Axios.prototype.request, context); | ||
const context = new Axios(defaultConfig); | ||
const instance = bind(Axios.prototype.request, context); | ||
// Copy axios.prototype to instance | ||
utils.extend(instance, Axios.prototype, context); | ||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true}); | ||
// Copy context to instance | ||
utils.extend(instance, context); | ||
utils.extend(instance, context, null, {allOwnKeys: true}); | ||
@@ -35,3 +45,3 @@ // Factory for creating new instances | ||
// Create the default instance to be exported | ||
var axios = createInstance(defaults); | ||
const axios = createInstance(defaults); | ||
@@ -42,10 +52,10 @@ // Expose Axios class to allow class inheritance | ||
// Expose Cancel & CancelToken | ||
axios.CanceledError = require('./cancel/CanceledError'); | ||
axios.CancelToken = require('./cancel/CancelToken'); | ||
axios.isCancel = require('./cancel/isCancel'); | ||
axios.VERSION = require('./env/data').version; | ||
axios.toFormData = require('./helpers/toFormData'); | ||
axios.CanceledError = CanceledError; | ||
axios.CancelToken = CancelToken; | ||
axios.isCancel = isCancel; | ||
axios.VERSION = VERSION; | ||
axios.toFormData = toFormData; | ||
// Expose AxiosError class | ||
axios.AxiosError = require('../lib/core/AxiosError'); | ||
axios.AxiosError = AxiosError; | ||
@@ -59,14 +69,12 @@ // alias for CanceledError for backward compatibility | ||
}; | ||
axios.spread = require('./helpers/spread'); | ||
axios.spread = spread; | ||
// Expose isAxiosError | ||
axios.isAxiosError = require('./helpers/isAxiosError'); | ||
axios.isAxiosError = isAxiosError; | ||
axios.formToJSON = function(thing) { | ||
axios.formToJSON = thing => { | ||
return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing); | ||
}; | ||
module.exports = axios; | ||
// Allow use of default import syntax in TypeScript | ||
module.exports.default = axios; | ||
export default axios; |
'use strict'; | ||
var AxiosError = require('../core/AxiosError'); | ||
var utils = require('../utils'); | ||
import AxiosError from '../core/AxiosError.js'; | ||
import utils from '../utils.js'; | ||
@@ -9,6 +9,7 @@ /** | ||
* | ||
* @class | ||
* @param {string=} message The message. | ||
* @param {Object=} config The config. | ||
* @param {Object=} request The request. | ||
* | ||
* @returns {CanceledError} The created error. | ||
*/ | ||
@@ -25,2 +26,2 @@ function CanceledError(message, config, request) { | ||
module.exports = CanceledError; | ||
export default CanceledError; |
'use strict'; | ||
var CanceledError = require('./CanceledError'); | ||
import CanceledError from './CanceledError.js'; | ||
@@ -8,112 +8,115 @@ /** | ||
* | ||
* @class | ||
* @param {Function} executor The executor function. | ||
* | ||
* @returns {CancelToken} | ||
*/ | ||
function CancelToken(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
class CancelToken { | ||
constructor(executor) { | ||
if (typeof executor !== 'function') { | ||
throw new TypeError('executor must be a function.'); | ||
} | ||
var resolvePromise; | ||
let resolvePromise; | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
this.promise = new Promise(function promiseExecutor(resolve) { | ||
resolvePromise = resolve; | ||
}); | ||
var token = this; | ||
const token = this; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(function(cancel) { | ||
if (!token._listeners) return; | ||
// eslint-disable-next-line func-names | ||
this.promise.then(cancel => { | ||
if (!token._listeners) return; | ||
var i = token._listeners.length; | ||
let i = token._listeners.length; | ||
while (i-- > 0) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
while (i-- > 0) { | ||
token._listeners[i](cancel); | ||
} | ||
token._listeners = null; | ||
}); | ||
// eslint-disable-next-line func-names | ||
this.promise.then = function(onfulfilled) { | ||
var _resolve; | ||
// eslint-disable-next-line func-names | ||
var promise = new Promise(function(resolve) { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
this.promise.then = onfulfilled => { | ||
let _resolve; | ||
// eslint-disable-next-line func-names | ||
const promise = new Promise(resolve => { | ||
token.subscribe(resolve); | ||
_resolve = resolve; | ||
}).then(onfulfilled); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
promise.cancel = function reject() { | ||
token.unsubscribe(_resolve); | ||
}; | ||
return promise; | ||
}; | ||
return promise; | ||
}; | ||
executor(function cancel(message, config, request) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
} | ||
executor(function cancel(message, config, request) { | ||
if (token.reason) { | ||
// Cancellation has already been requested | ||
return; | ||
token.reason = new CanceledError(message, config, request); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
token.reason = new CanceledError(message, config, request); | ||
resolvePromise(token.reason); | ||
}); | ||
} | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
CancelToken.prototype.throwIfRequested = function throwIfRequested() { | ||
if (this.reason) { | ||
throw this.reason; | ||
} | ||
}; | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
/** | ||
* Subscribe to the cancel signal | ||
*/ | ||
CancelToken.prototype.subscribe = function subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
subscribe(listener) { | ||
if (this.reason) { | ||
listener(this.reason); | ||
return; | ||
} | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
if (this._listeners) { | ||
this._listeners.push(listener); | ||
} else { | ||
this._listeners = [listener]; | ||
} | ||
} | ||
}; | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
/** | ||
* Unsubscribe from the cancel signal | ||
*/ | ||
CancelToken.prototype.unsubscribe = function unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
unsubscribe(listener) { | ||
if (!this._listeners) { | ||
return; | ||
} | ||
const index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
} | ||
} | ||
var index = this._listeners.indexOf(listener); | ||
if (index !== -1) { | ||
this._listeners.splice(index, 1); | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
static source() { | ||
let cancel; | ||
const token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token, | ||
cancel | ||
}; | ||
} | ||
}; | ||
} | ||
/** | ||
* Returns an object that contains a new `CancelToken` and a function that, when called, | ||
* cancels the `CancelToken`. | ||
*/ | ||
CancelToken.source = function source() { | ||
var cancel; | ||
var token = new CancelToken(function executor(c) { | ||
cancel = c; | ||
}); | ||
return { | ||
token: token, | ||
cancel: cancel | ||
}; | ||
}; | ||
module.exports = CancelToken; | ||
export default CancelToken; |
'use strict'; | ||
module.exports = function isCancel(value) { | ||
export default function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var buildURL = require('../helpers/buildURL'); | ||
var InterceptorManager = require('./InterceptorManager'); | ||
var dispatchRequest = require('./dispatchRequest'); | ||
var mergeConfig = require('./mergeConfig'); | ||
var buildFullPath = require('./buildFullPath'); | ||
var validator = require('../helpers/validator'); | ||
import utils from './../utils.js'; | ||
import buildURL from '../helpers/buildURL.js'; | ||
import InterceptorManager from './InterceptorManager.js'; | ||
import dispatchRequest from './dispatchRequest.js'; | ||
import mergeConfig from './mergeConfig.js'; | ||
import buildFullPath from './buildFullPath.js'; | ||
import validator from '../helpers/validator.js'; | ||
import AxiosHeaders from './AxiosHeaders.js'; | ||
var validators = validator.validators; | ||
const validators = validator.validators; | ||
/** | ||
@@ -16,114 +18,139 @@ * Create a new instance of Axios | ||
* @param {Object} instanceConfig The default config for the instance | ||
*/ | ||
function Axios(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
/** | ||
* Dispatch a request | ||
* | ||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) | ||
* @param {?Object} config | ||
* @return {Axios} A new instance of Axios | ||
*/ | ||
Axios.prototype.request = function request(configOrUrl, config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof configOrUrl === 'string') { | ||
config = config || {}; | ||
config.url = configOrUrl; | ||
} else { | ||
config = configOrUrl || {}; | ||
class Axios { | ||
constructor(instanceConfig) { | ||
this.defaults = instanceConfig; | ||
this.interceptors = { | ||
request: new InterceptorManager(), | ||
response: new InterceptorManager() | ||
}; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
/** | ||
* Dispatch a request | ||
* | ||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) | ||
* @param {?Object} config | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
request(configOrUrl, config) { | ||
/*eslint no-param-reassign:0*/ | ||
// Allow for axios('example/url'[, config]) a la fetch API | ||
if (typeof configOrUrl === 'string') { | ||
config = config || {}; | ||
config.url = configOrUrl; | ||
} else { | ||
config = configOrUrl || {}; | ||
} | ||
// Set config.method | ||
if (config.method) { | ||
config.method = config.method.toLowerCase(); | ||
} else if (this.defaults.method) { | ||
config.method = this.defaults.method.toLowerCase(); | ||
} else { | ||
config.method = 'get'; | ||
} | ||
config = mergeConfig(this.defaults, config); | ||
var transitional = config.transitional; | ||
const transitional = config.transitional; | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
// filter out skipped interceptors | ||
var requestInterceptorChain = []; | ||
var synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
if (transitional !== undefined) { | ||
validator.assertOptions(transitional, { | ||
silentJSONParsing: validators.transitional(validators.boolean), | ||
forcedJSONParsing: validators.transitional(validators.boolean), | ||
clarifyTimeoutError: validators.transitional(validators.boolean) | ||
}, false); | ||
} | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
// Set config.method | ||
config.method = (config.method || this.defaults.method || 'get').toLowerCase(); | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
// Flatten headers | ||
const defaultHeaders = config.headers && utils.merge( | ||
config.headers.common, | ||
config.headers[config.method] | ||
); | ||
var responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
defaultHeaders && utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
var promise; | ||
config.headers = new AxiosHeaders(config.headers, defaultHeaders); | ||
if (!synchronousRequestInterceptors) { | ||
var chain = [dispatchRequest, undefined]; | ||
// filter out skipped interceptors | ||
const requestInterceptorChain = []; | ||
let synchronousRequestInterceptors = true; | ||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { | ||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { | ||
return; | ||
} | ||
Array.prototype.unshift.apply(chain, requestInterceptorChain); | ||
chain = chain.concat(responseInterceptorChain); | ||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; | ||
promise = Promise.resolve(config); | ||
while (chain.length) { | ||
promise = promise.then(chain.shift(), chain.shift()); | ||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
const responseInterceptorChain = []; | ||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { | ||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); | ||
}); | ||
let promise; | ||
let i = 0; | ||
let len; | ||
if (!synchronousRequestInterceptors) { | ||
const chain = [dispatchRequest.bind(this), undefined]; | ||
chain.unshift.apply(chain, requestInterceptorChain); | ||
chain.push.apply(chain, responseInterceptorChain); | ||
len = chain.length; | ||
promise = Promise.resolve(config); | ||
while (i < len) { | ||
promise = promise.then(chain[i++], chain[i++]); | ||
} | ||
return promise; | ||
} | ||
return promise; | ||
} | ||
len = requestInterceptorChain.length; | ||
let newConfig = config; | ||
var newConfig = config; | ||
while (requestInterceptorChain.length) { | ||
var onFulfilled = requestInterceptorChain.shift(); | ||
var onRejected = requestInterceptorChain.shift(); | ||
i = 0; | ||
while (i < len) { | ||
const onFulfilled = requestInterceptorChain[i++]; | ||
const onRejected = requestInterceptorChain[i++]; | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
} catch (error) { | ||
onRejected.call(this, error); | ||
break; | ||
} | ||
} | ||
try { | ||
newConfig = onFulfilled(newConfig); | ||
promise = dispatchRequest.call(this, newConfig); | ||
} catch (error) { | ||
onRejected(error); | ||
break; | ||
return Promise.reject(error); | ||
} | ||
} | ||
try { | ||
promise = dispatchRequest(newConfig); | ||
} catch (error) { | ||
return Promise.reject(error); | ||
i = 0; | ||
len = responseInterceptorChain.length; | ||
while (i < len) { | ||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]); | ||
} | ||
return promise; | ||
} | ||
while (responseInterceptorChain.length) { | ||
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); | ||
getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
const fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
} | ||
} | ||
return promise; | ||
}; | ||
Axios.prototype.getUri = function getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
}; | ||
// Provide aliases for supported request methods | ||
@@ -134,4 +161,4 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
method, | ||
url, | ||
data: (config || {}).data | ||
@@ -148,8 +175,8 @@ })); | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
method, | ||
headers: isForm ? { | ||
'Content-Type': 'multipart/form-data' | ||
} : {}, | ||
url: url, | ||
data: data | ||
url, | ||
data | ||
})); | ||
@@ -164,2 +191,2 @@ }; | ||
module.exports = Axios; | ||
export default Axios; |
'use strict'; | ||
var utils = require('../utils'); | ||
import utils from '../utils.js'; | ||
@@ -13,2 +13,3 @@ /** | ||
* @param {Object} [response] The response. | ||
* | ||
* @returns {Error} The created error. | ||
@@ -55,4 +56,4 @@ */ | ||
var prototype = AxiosError.prototype; | ||
var descriptors = {}; | ||
const prototype = AxiosError.prototype; | ||
const descriptors = {}; | ||
@@ -73,3 +74,3 @@ [ | ||
// eslint-disable-next-line func-names | ||
].forEach(function(code) { | ||
].forEach(code => { | ||
descriptors[code] = {value: code}; | ||
@@ -82,7 +83,9 @@ }); | ||
// eslint-disable-next-line func-names | ||
AxiosError.from = function(error, code, config, request, response, customProps) { | ||
var axiosError = Object.create(prototype); | ||
AxiosError.from = (error, code, config, request, response, customProps) => { | ||
const axiosError = Object.create(prototype); | ||
utils.toFlatObject(error, axiosError, function filter(obj) { | ||
return obj !== Error.prototype; | ||
}, prop => { | ||
return prop !== 'isAxiosError'; | ||
}); | ||
@@ -101,2 +104,2 @@ | ||
module.exports = AxiosError; | ||
export default AxiosError; |
'use strict'; | ||
var isAbsoluteURL = require('../helpers/isAbsoluteURL'); | ||
var combineURLs = require('../helpers/combineURLs'); | ||
import isAbsoluteURL from '../helpers/isAbsoluteURL.js'; | ||
import combineURLs from '../helpers/combineURLs.js'; | ||
@@ -13,5 +13,6 @@ /** | ||
* @param {string} requestedURL Absolute or relative URL to combine | ||
* | ||
* @returns {string} The combined full path | ||
*/ | ||
module.exports = function buildFullPath(baseURL, requestedURL) { | ||
export default function buildFullPath(baseURL, requestedURL) { | ||
if (baseURL && !isAbsoluteURL(requestedURL)) { | ||
@@ -21,2 +22,2 @@ return combineURLs(baseURL, requestedURL); | ||
return requestedURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var transformData = require('./transformData'); | ||
var isCancel = require('../cancel/isCancel'); | ||
var defaults = require('../defaults'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
var normalizeHeaderName = require('../helpers/normalizeHeaderName'); | ||
import transformData from './transformData.js'; | ||
import isCancel from '../cancel/isCancel.js'; | ||
import defaults from '../defaults/index.js'; | ||
import CanceledError from '../cancel/CanceledError.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
/** | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
* | ||
* @param {Object} config The config that is to be used for the request | ||
* | ||
* @returns {void} | ||
*/ | ||
@@ -27,9 +30,9 @@ function throwIfCancellationRequested(config) { | ||
* @param {object} config The config that is to be used for the request | ||
* | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
module.exports = function dispatchRequest(config) { | ||
export default function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
config.headers = AxiosHeaders.from(config.headers); | ||
@@ -39,27 +42,7 @@ // Transform request data | ||
config, | ||
config.data, | ||
config.headers, | ||
null, | ||
config.transformRequest | ||
); | ||
normalizeHeaderName(config.headers, 'Accept'); | ||
normalizeHeaderName(config.headers, 'Content-Type'); | ||
const adapter = config.adapter || defaults.adapter; | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers | ||
); | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
var adapter = config.adapter || defaults.adapter; | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
@@ -71,8 +54,8 @@ throwIfCancellationRequested(config); | ||
config, | ||
response.data, | ||
response.headers, | ||
response.status, | ||
config.transformResponse | ||
config.transformResponse, | ||
response | ||
); | ||
response.headers = AxiosHeaders.from(response.headers); | ||
return response; | ||
@@ -87,7 +70,6 @@ }, function onAdapterRejection(reason) { | ||
config, | ||
reason.response.data, | ||
reason.response.headers, | ||
reason.response.status, | ||
config.transformResponse | ||
config.transformResponse, | ||
reason.response | ||
); | ||
reason.response.headers = AxiosHeaders.from(reason.response.headers); | ||
} | ||
@@ -98,2 +80,2 @@ } | ||
}); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
class InterceptorManager { | ||
constructor() { | ||
this.handlers = []; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled: fulfilled, | ||
rejected: rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
}; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
*/ | ||
InterceptorManager.prototype.eject = function eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
use(fulfilled, rejected, options) { | ||
this.handlers.push({ | ||
fulfilled, | ||
rejected, | ||
synchronous: options ? options.synchronous : false, | ||
runWhen: options ? options.runWhen : null | ||
}); | ||
return this.handlers.length - 1; | ||
} | ||
}; | ||
/** | ||
* Clear all interceptors from the stack | ||
*/ | ||
InterceptorManager.prototype.clear = function clear() { | ||
if (this.handlers) { | ||
this.handlers = []; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
* | ||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise | ||
*/ | ||
eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
} | ||
}; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
*/ | ||
InterceptorManager.prototype.forEach = function forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
/** | ||
* Clear all interceptors from the stack | ||
* | ||
* @returns {void} | ||
*/ | ||
clear() { | ||
if (this.handlers) { | ||
this.handlers = []; | ||
} | ||
}); | ||
}; | ||
} | ||
module.exports = InterceptorManager; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
* | ||
* @returns {void} | ||
*/ | ||
forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
} | ||
}); | ||
} | ||
} | ||
export default InterceptorManager; |
'use strict'; | ||
var utils = require('../utils'); | ||
import utils from '../utils.js'; | ||
@@ -11,8 +11,9 @@ /** | ||
* @param {Object} config2 | ||
* | ||
* @returns {Object} New object resulting from merging config2 to config1 | ||
*/ | ||
module.exports = function mergeConfig(config1, config2) { | ||
export default function mergeConfig(config1, config2) { | ||
// eslint-disable-next-line no-param-reassign | ||
config2 = config2 || {}; | ||
var config = {}; | ||
const config = {}; | ||
@@ -64,3 +65,3 @@ function getMergedValue(target, source) { | ||
var mergeMap = { | ||
const mergeMap = { | ||
'url': valueFromConfig2, | ||
@@ -96,4 +97,4 @@ 'method': valueFromConfig2, | ||
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { | ||
var merge = mergeMap[prop] || mergeDeepProperties; | ||
var configValue = merge(prop); | ||
const merge = mergeMap[prop] || mergeDeepProperties; | ||
const configValue = merge(prop); | ||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); | ||
@@ -103,2 +104,2 @@ }); | ||
return config; | ||
}; | ||
} |
'use strict'; | ||
var AxiosError = require('./AxiosError'); | ||
import AxiosError from './AxiosError.js'; | ||
@@ -11,5 +11,7 @@ /** | ||
* @param {object} response The response. | ||
* | ||
* @returns {object} The response. | ||
*/ | ||
module.exports = function settle(resolve, reject, response) { | ||
var validateStatus = response.config.validateStatus; | ||
export default function settle(resolve, reject, response) { | ||
const validateStatus = response.config.validateStatus; | ||
if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
@@ -26,2 +28,2 @@ resolve(response); | ||
} | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
var defaults = require('../defaults'); | ||
import utils from './../utils.js'; | ||
import defaults from '../defaults/index.js'; | ||
import AxiosHeaders from '../core/AxiosHeaders.js'; | ||
@@ -9,16 +10,20 @@ /** | ||
* | ||
* @param {Object|String} data The data to be transformed | ||
* @param {Array} headers The headers for the request or response | ||
* @param {Number} status HTTP status code | ||
* @param {Array|Function} fns A single function or Array of functions | ||
* @param {?Object} response The response object | ||
* | ||
* @returns {*} The resulting transformed data | ||
*/ | ||
module.exports = function transformData(data, headers, status, fns) { | ||
var context = this || defaults; | ||
/*eslint no-param-reassign:0*/ | ||
export default function transformData(fns, response) { | ||
const config = this || defaults; | ||
const context = response || config; | ||
const headers = AxiosHeaders.from(context.headers); | ||
let data = context.data; | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn.call(context, data, headers, status); | ||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined); | ||
}); | ||
headers.normalize(); | ||
return data; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('../utils'); | ||
var normalizeHeaderName = require('../helpers/normalizeHeaderName'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var transitionalDefaults = require('./transitional'); | ||
var toFormData = require('../helpers/toFormData'); | ||
var toURLEncodedForm = require('../helpers/toURLEncodedForm'); | ||
var platform = require('../platform'); | ||
var formDataToJSON = require('../helpers/formDataToJSON'); | ||
import utils from '../utils.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import transitionalDefaults from './transitional.js'; | ||
import toFormData from '../helpers/toFormData.js'; | ||
import toURLEncodedForm from '../helpers/toURLEncodedForm.js'; | ||
import platform from '../platform/index.js'; | ||
import formDataToJSON from '../helpers/formDataToJSON.js'; | ||
import adapters from '../adapters/index.js'; | ||
var DEFAULT_CONTENT_TYPE = { | ||
const DEFAULT_CONTENT_TYPE = { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
}; | ||
function setContentTypeIfUnset(headers, value) { | ||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { | ||
headers['Content-Type'] = value; | ||
} | ||
} | ||
/** | ||
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP | ||
* adapter | ||
* | ||
* @returns {Function} | ||
*/ | ||
function getDefaultAdapter() { | ||
var adapter; | ||
let adapter; | ||
if (typeof XMLHttpRequest !== 'undefined') { | ||
// For browsers use XHR adapter | ||
adapter = require('../adapters/xhr'); | ||
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { | ||
adapter = adapters.getAdapter('xhr'); | ||
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') { | ||
// For node use HTTP adapter | ||
adapter = require('../adapters/http'); | ||
adapter = adapters.getAdapter('http'); | ||
} | ||
@@ -34,2 +34,12 @@ return adapter; | ||
/** | ||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version | ||
* of the input | ||
* | ||
* @param {any} rawValue - The value to be stringified. | ||
* @param {Function} parser - A function that parses a string into a JavaScript object. | ||
* @param {Function} encoder - A function that takes a value and returns a string. | ||
* | ||
* @returns {string} A stringified version of the rawValue. | ||
*/ | ||
function stringifySafely(rawValue, parser, encoder) { | ||
@@ -50,3 +60,3 @@ if (utils.isString(rawValue)) { | ||
var defaults = { | ||
const defaults = { | ||
@@ -58,9 +68,6 @@ transitional: transitionalDefaults, | ||
transformRequest: [function transformRequest(data, headers) { | ||
normalizeHeaderName(headers, 'Accept'); | ||
normalizeHeaderName(headers, 'Content-Type'); | ||
const contentType = headers.getContentType() || ''; | ||
const hasJSONContentType = contentType.indexOf('application/json') > -1; | ||
const isObjectPayload = utils.isObject(data); | ||
var contentType = headers && headers['Content-Type'] || ''; | ||
var hasJSONContentType = contentType.indexOf('application/json') > -1; | ||
var isObjectPayload = utils.isObject(data); | ||
if (isObjectPayload && utils.isHTMLForm(data)) { | ||
@@ -70,3 +77,3 @@ data = new FormData(data); | ||
var isFormData = utils.isFormData(data); | ||
const isFormData = utils.isFormData(data); | ||
@@ -92,10 +99,10 @@ if (isFormData) { | ||
if (utils.isURLSearchParams(data)) { | ||
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); | ||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false); | ||
return data.toString(); | ||
} | ||
var isFileList; | ||
let isFileList; | ||
if (isObjectPayload) { | ||
if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) { | ||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) { | ||
return toURLEncodedForm(data, this.formSerializer).toString(); | ||
@@ -105,3 +112,3 @@ } | ||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) { | ||
var _FormData = this.env && this.env.FormData; | ||
const _FormData = this.env && this.env.FormData; | ||
@@ -117,3 +124,3 @@ return toFormData( | ||
if (isObjectPayload || hasJSONContentType ) { | ||
setContentTypeIfUnset(headers, 'application/json'); | ||
headers.setContentType('application/json', false); | ||
return stringifySafely(data); | ||
@@ -126,9 +133,9 @@ } | ||
transformResponse: [function transformResponse(data) { | ||
var transitional = this.transitional || defaults.transitional; | ||
var forcedJSONParsing = transitional && transitional.forcedJSONParsing; | ||
var JSONRequested = this.responseType === 'json'; | ||
const transitional = this.transitional || defaults.transitional; | ||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing; | ||
const JSONRequested = this.responseType === 'json'; | ||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) { | ||
var silentJSONParsing = transitional && transitional.silentJSONParsing; | ||
var strictJSONParsing = !silentJSONParsing && JSONRequested; | ||
const silentJSONParsing = transitional && transitional.silentJSONParsing; | ||
const strictJSONParsing = !silentJSONParsing && JSONRequested; | ||
@@ -186,2 +193,2 @@ try { | ||
module.exports = defaults; | ||
export default defaults; |
'use strict'; | ||
module.exports = { | ||
export default { | ||
silentJSONParsing: true, | ||
@@ -5,0 +5,0 @@ forcedJSONParsing: true, |
@@ -1,2 +0,2 @@ | ||
// eslint-disable-next-line strict | ||
module.exports = require('form-data'); | ||
import FormData from 'form-data'; | ||
export default FormData; |
@@ -1,3 +0,1 @@ | ||
module.exports = { | ||
"version": "1.0.0-alpha.1" | ||
}; | ||
export const VERSION = "1.0.0"; |
'use strict'; | ||
var toFormData = require('./toFormData'); | ||
import toFormData from './toFormData.js'; | ||
/** | ||
* It encodes a string by replacing all characters that are not in the unreserved set with | ||
* their percent-encoded equivalents | ||
* | ||
* @param {string} str - The string to encode. | ||
* | ||
* @returns {string} The encoded string. | ||
*/ | ||
function encode(str) { | ||
var charMap = { | ||
const charMap = { | ||
'!': '%21', | ||
@@ -15,3 +23,3 @@ "'": '%27', | ||
}; | ||
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) { | ||
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) { | ||
return charMap[match]; | ||
@@ -21,2 +29,10 @@ }); | ||
/** | ||
* It takes a params object and converts it to a FormData object | ||
* | ||
* @param {Object<string, any>} params - The parameters to be converted to a FormData object. | ||
* @param {Object<string, any>} options - The options object passed to the Axios constructor. | ||
* | ||
* @returns {void} | ||
*/ | ||
function AxiosURLSearchParams(params, options) { | ||
@@ -28,3 +44,3 @@ this._pairs = []; | ||
var prototype = AxiosURLSearchParams.prototype; | ||
const prototype = AxiosURLSearchParams.prototype; | ||
@@ -36,3 +52,3 @@ prototype.append = function append(name, value) { | ||
prototype.toString = function toString(encoder) { | ||
var _encode = encoder ? function(value) { | ||
const _encode = encoder ? function(value) { | ||
return encoder.call(this, value, encode); | ||
@@ -46,2 +62,2 @@ } : encode; | ||
module.exports = AxiosURLSearchParams; | ||
export default AxiosURLSearchParams; |
'use strict'; | ||
module.exports = function bind(fn, thisArg) { | ||
export default function bind(fn, thisArg) { | ||
return function wrap() { | ||
return fn.apply(thisArg, arguments); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('../utils'); | ||
var AxiosURLSearchParams = require('../helpers/AxiosURLSearchParams'); | ||
import utils from '../utils.js'; | ||
import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js'; | ||
/** | ||
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their | ||
* URI encoded counterparts | ||
* | ||
* @param {string} val The value to be encoded. | ||
* | ||
* @returns {string} The encoded value. | ||
*/ | ||
function encode(val) { | ||
@@ -22,5 +30,6 @@ return encodeURIComponent(val). | ||
* @param {?object} options | ||
* | ||
* @returns {string} The formatted url | ||
*/ | ||
module.exports = function buildURL(url, params, options) { | ||
export default function buildURL(url, params, options) { | ||
/*eslint no-param-reassign:0*/ | ||
@@ -31,3 +40,3 @@ if (!params) { | ||
var hashmarkIndex = url.indexOf('#'); | ||
const hashmarkIndex = url.indexOf('#'); | ||
@@ -38,5 +47,5 @@ if (hashmarkIndex !== -1) { | ||
var _encode = options && options.encode || encode; | ||
const _encode = options && options.encode || encode; | ||
var serializerParams = utils.isURLSearchParams(params) ? | ||
const serializerParams = utils.isURLSearchParams(params) ? | ||
params.toString() : | ||
@@ -50,2 +59,2 @@ new AxiosURLSearchParams(params, options).toString(_encode); | ||
return url; | ||
}; | ||
} |
@@ -8,8 +8,9 @@ 'use strict'; | ||
* @param {string} relativeURL The relative URL | ||
* | ||
* @returns {string} The combined URL | ||
*/ | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
export default function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.isStandardBrowserEnv ? | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
var cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
// Standard browser envs support document.cookie | ||
(function standardBrowserEnv() { | ||
return { | ||
write: function write(name, value, expires, path, domain, secure) { | ||
const cookie = []; | ||
cookie.push(name + '=' + encodeURIComponent(value)); | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
if (secure === true) { | ||
cookie.push('secure'); | ||
} | ||
document.cookie = cookie.join('; '); | ||
}, | ||
document.cookie = cookie.join('; '); | ||
}, | ||
read: function read(name) { | ||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
read: function read(name) { | ||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); | ||
return (match ? decodeURIComponent(match[3]) : null); | ||
}, | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
remove: function remove(name) { | ||
this.write(name, '', Date.now() - 86400000); | ||
} | ||
}; | ||
})() : | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})() | ||
); | ||
// Non standard browser env (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return { | ||
write: function write() {}, | ||
read: function read() { return null; }, | ||
remove: function remove() {} | ||
}; | ||
})(); |
@@ -12,4 +12,6 @@ 'use strict'; | ||
* @param {string} [docs] The documentation URL to get further details | ||
* | ||
* @returns {void} | ||
*/ | ||
module.exports = function deprecatedMethod(method, instead, docs) { | ||
export default function deprecatedMethod(method, instead, docs) { | ||
try { | ||
@@ -25,2 +27,2 @@ console.warn( | ||
} catch (e) { /* Ignore */ } | ||
}; | ||
} |
'use strict'; | ||
var utils = require('../utils'); | ||
import utils from '../utils.js'; | ||
/** | ||
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z'] | ||
* | ||
* @param {string} name - The name of the property to get. | ||
* | ||
* @returns An array of strings. | ||
*/ | ||
function parsePropPath(name) { | ||
@@ -10,3 +17,3 @@ // foo[x][y][z] | ||
// foo x y z | ||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function(match) { | ||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => { | ||
return match[0] === '[]' ? '' : match[1] || match[0]; | ||
@@ -16,8 +23,15 @@ }); | ||
/** | ||
* Convert an array to an object. | ||
* | ||
* @param {Array<any>} arr - The array to convert to an object. | ||
* | ||
* @returns An object with the same keys and values as the array. | ||
*/ | ||
function arrayToObject(arr) { | ||
var obj = {}; | ||
var keys = Object.keys(arr); | ||
var i; | ||
var len = keys.length; | ||
var key; | ||
const obj = {}; | ||
const keys = Object.keys(arr); | ||
let i; | ||
const len = keys.length; | ||
let key; | ||
for (i = 0; i < len; i++) { | ||
@@ -30,11 +44,18 @@ key = keys[i]; | ||
/** | ||
* It takes a FormData object and returns a JavaScript object | ||
* | ||
* @param {string} formData The FormData object to convert to JSON. | ||
* | ||
* @returns {Object<string, any> | null} The converted object. | ||
*/ | ||
function formDataToJSON(formData) { | ||
function buildPath(path, value, target, index) { | ||
var name = path[index++]; | ||
var isNumericKey = Number.isFinite(+name); | ||
var isLast = index >= path.length; | ||
let name = path[index++]; | ||
const isNumericKey = Number.isFinite(+name); | ||
const isLast = index >= path.length; | ||
name = !name && utils.isArray(target) ? target.length : name; | ||
if (isLast) { | ||
if (utils.hasOwnProperty(target, name)) { | ||
if (utils.hasOwnProp(target, name)) { | ||
target[name] = [target[name], value]; | ||
@@ -52,3 +73,3 @@ } else { | ||
var result = buildPath(path, value, target[name], index); | ||
const result = buildPath(path, value, target[name], index); | ||
@@ -63,5 +84,5 @@ if (result && utils.isArray(target[name])) { | ||
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) { | ||
var obj = {}; | ||
const obj = {}; | ||
utils.forEachEntry(formData, function(name, value) { | ||
utils.forEachEntry(formData, (name, value) => { | ||
buildPath(parsePropPath(name), value, obj, 0); | ||
@@ -76,2 +97,2 @@ }); | ||
module.exports = formDataToJSON; | ||
export default formDataToJSON; |
'use strict'; | ||
var AxiosError = require('../core/AxiosError'); | ||
var parseProtocol = require('./parseProtocol'); | ||
var platform = require('../platform'); | ||
import AxiosError from '../core/AxiosError.js'; | ||
import parseProtocol from './parseProtocol.js'; | ||
import platform from '../platform/index.js'; | ||
var DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/; | ||
const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/; | ||
/** | ||
* Parse data uri to a Buffer or Blob | ||
* | ||
* @param {String} uri | ||
@@ -15,7 +16,8 @@ * @param {?Boolean} asBlob | ||
* @param {?Function} options.Blob | ||
* | ||
* @returns {Buffer|Blob} | ||
*/ | ||
module.exports = function fromDataURI(uri, asBlob, options) { | ||
var _Blob = options && options.Blob || platform.classes.Blob; | ||
var protocol = parseProtocol(uri); | ||
export default function fromDataURI(uri, asBlob, options) { | ||
const _Blob = options && options.Blob || platform.classes.Blob; | ||
const protocol = parseProtocol(uri); | ||
@@ -29,3 +31,3 @@ if (asBlob === undefined && _Blob) { | ||
var match = DATA_URL_PATTERN.exec(uri); | ||
const match = DATA_URL_PATTERN.exec(uri); | ||
@@ -36,6 +38,6 @@ if (!match) { | ||
var mime = match[1]; | ||
var isBase64 = match[2]; | ||
var body = match[3]; | ||
var buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8'); | ||
const mime = match[1]; | ||
const isBase64 = match[2]; | ||
const body = match[3]; | ||
const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8'); | ||
@@ -54,2 +56,2 @@ if (asBlob) { | ||
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT); | ||
}; | ||
} |
@@ -7,5 +7,6 @@ 'use strict'; | ||
* @param {string} url The URL to test | ||
* | ||
* @returns {boolean} True if the specified URL is absolute, otherwise false | ||
*/ | ||
module.exports = function isAbsoluteURL(url) { | ||
export default function isAbsoluteURL(url) { | ||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). | ||
@@ -15,2 +16,2 @@ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed | ||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
@@ -9,6 +9,7 @@ /** | ||
* @param {*} payload The value to test | ||
* | ||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false | ||
*/ | ||
module.exports = function isAxiosError(payload) { | ||
export default function isAxiosError(payload) { | ||
return utils.isObject(payload) && (payload.isAxiosError === true); | ||
}; | ||
} |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
export default platform.isStandardBrowserEnv ? | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
var msie = /(msie|trident)/i.test(navigator.userAgent); | ||
var urlParsingNode = document.createElement('a'); | ||
var originURL; | ||
// Standard browser envs have full support of the APIs needed to test | ||
// whether the request URL is of the same origin as current location. | ||
(function standardBrowserEnv() { | ||
const msie = /(msie|trident)/i.test(navigator.userAgent); | ||
const urlParsingNode = document.createElement('a'); | ||
let originURL; | ||
/** | ||
* Parse a URL to discover it's components | ||
* | ||
* @param {String} url The URL to be parsed | ||
* @returns {Object} | ||
*/ | ||
function resolveURL(url) { | ||
var href = url; | ||
/** | ||
* Parse a URL to discover it's components | ||
* | ||
* @param {String} url The URL to be parsed | ||
* @returns {Object} | ||
*/ | ||
function resolveURL(url) { | ||
let href = url; | ||
if (msie) { | ||
// IE needs attribute set twice to normalize properties | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.href; | ||
} | ||
if (msie) { | ||
// IE needs attribute set twice to normalize properties | ||
urlParsingNode.setAttribute('href', href); | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
href = urlParsingNode.href; | ||
} | ||
originURL = resolveURL(window.location.href); | ||
urlParsingNode.setAttribute('href', href); | ||
/** | ||
* Determine if a URL shares the same origin as the current location | ||
* | ||
* @param {String} requestURL The URL to test | ||
* @returns {boolean} True if URL shares the same origin, otherwise false | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils | ||
return { | ||
href: urlParsingNode.href, | ||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', | ||
host: urlParsingNode.host, | ||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', | ||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', | ||
hostname: urlParsingNode.hostname, | ||
port: urlParsingNode.port, | ||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ? | ||
urlParsingNode.pathname : | ||
'/' + urlParsingNode.pathname | ||
}; | ||
})() : | ||
} | ||
// Non standard browser envs (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})() | ||
); | ||
originURL = resolveURL(window.location.href); | ||
/** | ||
* Determine if a URL shares the same origin as the current location | ||
* | ||
* @param {String} requestURL The URL to test | ||
* @returns {boolean} True if URL shares the same origin, otherwise false | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
parsed.host === originURL.host); | ||
}; | ||
})() : | ||
// Non standard browser envs (web workers, react-native) lack needed support. | ||
(function nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})(); |
// eslint-disable-next-line strict | ||
module.exports = null; | ||
export default null; |
'use strict'; | ||
var utils = require('./../utils'); | ||
import utils from './../utils.js'; | ||
// Headers whose duplicates are ignored by node | ||
// RawAxiosHeaders whose duplicates are ignored by node | ||
// c.f. https://nodejs.org/api/http.html#http_message_headers | ||
var ignoreDuplicateOf = [ | ||
const ignoreDuplicateOf = utils.toObjectSet([ | ||
'age', 'authorization', 'content-length', 'content-type', 'etag', | ||
@@ -12,3 +12,3 @@ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', | ||
'referer', 'retry-after', 'user-agent' | ||
]; | ||
]); | ||
@@ -25,27 +25,29 @@ /** | ||
* | ||
* @param {String} headers Headers needing to be parsed | ||
* @param {String} rawHeaders Headers needing to be parsed | ||
* | ||
* @returns {Object} Headers parsed into an object | ||
*/ | ||
module.exports = function parseHeaders(headers) { | ||
var parsed = {}; | ||
var key; | ||
var val; | ||
var i; | ||
export default rawHeaders => { | ||
const parsed = {}; | ||
let key; | ||
let val; | ||
let i; | ||
if (!headers) { return parsed; } | ||
utils.forEach(headers.split('\n'), function parser(line) { | ||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) { | ||
i = line.indexOf(':'); | ||
key = utils.trim(line.slice(0, i)).toLowerCase(); | ||
val = utils.trim(line.slice(i + 1)); | ||
key = line.substring(0, i).trim().toLowerCase(); | ||
val = line.substring(i + 1).trim(); | ||
if (key) { | ||
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); | ||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) { | ||
return; | ||
} | ||
if (key === 'set-cookie') { | ||
if (parsed[key]) { | ||
parsed[key].push(val); | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
parsed[key] = [val]; | ||
} | ||
} else { | ||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; | ||
} | ||
@@ -52,0 +54,0 @@ }); |
'use strict'; | ||
module.exports = function parseProtocol(url) { | ||
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); | ||
export default function parseProtocol(url) { | ||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url); | ||
return match && match[1] || ''; | ||
}; | ||
} |
@@ -21,8 +21,9 @@ 'use strict'; | ||
* @param {Function} callback | ||
* | ||
* @returns {Function} | ||
*/ | ||
module.exports = function spread(callback) { | ||
export default function spread(callback) { | ||
return function wrap(arr) { | ||
return callback.apply(null, arr); | ||
}; | ||
}; | ||
} |
'use strict'; | ||
var utils = require('../utils'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var envFormData = require('../env/classes/FormData'); | ||
import utils from '../utils.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
import envFormData from '../env/classes/FormData.js'; | ||
/** | ||
* Determines if the given thing is a array or js object. | ||
* | ||
* @param {string} thing - The object or array to be visited. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isVisitable(thing) { | ||
@@ -11,2 +18,9 @@ return utils.isPlainObject(thing) || utils.isArray(thing); | ||
/** | ||
* It removes the brackets from the end of a string | ||
* | ||
* @param {string} key - The key of the parameter. | ||
* | ||
* @returns {string} the key without the brackets. | ||
*/ | ||
function removeBrackets(key) { | ||
@@ -16,2 +30,11 @@ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key; | ||
/** | ||
* It takes a path, a key, and a boolean, and returns a string | ||
* | ||
* @param {string} path - The path to the current key. | ||
* @param {string} key - The key of the current object being iterated over. | ||
* @param {string} dots - If true, the key will be rendered with dots instead of brackets. | ||
* | ||
* @returns {string} The path to the current key. | ||
*/ | ||
function renderKey(path, key, dots) { | ||
@@ -26,2 +49,9 @@ if (!path) return key; | ||
/** | ||
* If the array is an array and none of its elements are visitable, then it's a flat array. | ||
* | ||
* @param {Array<any>} arr - The array to check | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isFlatArray(arr) { | ||
@@ -31,6 +61,13 @@ return utils.isArray(arr) && !arr.some(isVisitable); | ||
var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) { | ||
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) { | ||
return /^is[A-Z]/.test(prop); | ||
}); | ||
/** | ||
* If the thing is a FormData object, return true, otherwise return false. | ||
* | ||
* @param {unknown} thing - The thing to check. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function isSpecCompliant(thing) { | ||
@@ -42,2 +79,3 @@ return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]; | ||
* Convert a data object to FormData | ||
* | ||
* @param {Object} obj | ||
@@ -50,5 +88,15 @@ * @param {?Object} [formData] | ||
* @param {?Boolean} [options.indexes = false] | ||
* | ||
* @returns {Object} | ||
**/ | ||
/** | ||
* It converts an object into a FormData object | ||
* | ||
* @param {Object<any, any>} obj - The object to convert to form data. | ||
* @param {string} formData - The FormData object to append to. | ||
* @param {Object<string, any>} options | ||
* | ||
* @returns | ||
*/ | ||
function toFormData(obj, formData, options) { | ||
@@ -72,9 +120,9 @@ if (!utils.isObject(obj)) { | ||
var metaTokens = options.metaTokens; | ||
const metaTokens = options.metaTokens; | ||
// eslint-disable-next-line no-use-before-define | ||
var visitor = options.visitor || defaultVisitor; | ||
var dots = options.dots; | ||
var indexes = options.indexes; | ||
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob; | ||
var useBlob = _Blob && isSpecCompliant(formData); | ||
const visitor = options.visitor || defaultVisitor; | ||
const dots = options.dots; | ||
const indexes = options.indexes; | ||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob; | ||
const useBlob = _Blob && isSpecCompliant(formData); | ||
@@ -104,2 +152,3 @@ if (!utils.isFunction(visitor)) { | ||
/** | ||
* Default visitor. | ||
* | ||
@@ -110,6 +159,7 @@ * @param {*} value | ||
* @this {FormData} | ||
* | ||
* @returns {boolean} return true to visit the each prop of the value recursively | ||
*/ | ||
function defaultVisitor(value, key, path) { | ||
var arr = value; | ||
let arr = value; | ||
@@ -149,8 +199,8 @@ if (value && !path && typeof value === 'object') { | ||
var stack = []; | ||
const stack = []; | ||
var exposedHelpers = Object.assign(predicates, { | ||
defaultVisitor: defaultVisitor, | ||
convertValue: convertValue, | ||
isVisitable: isVisitable | ||
const exposedHelpers = Object.assign(predicates, { | ||
defaultVisitor, | ||
convertValue, | ||
isVisitable | ||
}); | ||
@@ -168,3 +218,3 @@ | ||
utils.forEach(value, function each(el, key) { | ||
var result = !utils.isUndefined(el) && visitor.call( | ||
const result = !utils.isUndefined(el) && visitor.call( | ||
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers | ||
@@ -190,2 +240,2 @@ ); | ||
module.exports = toFormData; | ||
export default toFormData; |
'use strict'; | ||
var utils = require('../utils'); | ||
var toFormData = require('./toFormData'); | ||
var platform = require('../platform/'); | ||
import utils from '../utils.js'; | ||
import toFormData from './toFormData.js'; | ||
import platform from '../platform/index.js'; | ||
module.exports = function toURLEncodedForm(data, options) { | ||
export default function toURLEncodedForm(data, options) { | ||
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({ | ||
@@ -18,2 +18,2 @@ visitor: function(value, key, path, helpers) { | ||
}, options)); | ||
}; | ||
} |
'use strict'; | ||
var VERSION = require('../env/data').version; | ||
var AxiosError = require('../core/AxiosError'); | ||
import {VERSION} from '../env/data.js'; | ||
import AxiosError from '../core/AxiosError.js'; | ||
var validators = {}; | ||
const validators = {}; | ||
// eslint-disable-next-line func-names | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { | ||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => { | ||
validators[type] = function validator(thing) { | ||
@@ -15,9 +15,11 @@ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; | ||
var deprecatedWarnings = {}; | ||
const deprecatedWarnings = {}; | ||
/** | ||
* Transitional option validator | ||
* | ||
* @param {function|boolean?} validator - set to false if the transitional option has been removed | ||
* @param {string?} version - deprecated version / removed since version | ||
* @param {string?} message - some message with additional info | ||
* | ||
* @returns {function} | ||
@@ -31,3 +33,3 @@ */ | ||
// eslint-disable-next-line func-names | ||
return function(value, opt, opts) { | ||
return (value, opt, opts) => { | ||
if (validator === false) { | ||
@@ -57,5 +59,8 @@ throw new AxiosError( | ||
* Assert object's properties type | ||
* | ||
* @param {object} options | ||
* @param {object} schema | ||
* @param {boolean?} allowUnknown | ||
* | ||
* @returns {object} | ||
*/ | ||
@@ -67,10 +72,10 @@ | ||
} | ||
var keys = Object.keys(options); | ||
var i = keys.length; | ||
const keys = Object.keys(options); | ||
let i = keys.length; | ||
while (i-- > 0) { | ||
var opt = keys[i]; | ||
var validator = schema[opt]; | ||
const opt = keys[i]; | ||
const validator = schema[opt]; | ||
if (validator) { | ||
var value = options[opt]; | ||
var result = value === undefined || validator(value, opt, options); | ||
const value = options[opt]; | ||
const result = value === undefined || validator(value, opt, options); | ||
if (result !== true) { | ||
@@ -87,5 +92,5 @@ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); | ||
module.exports = { | ||
assertOptions: assertOptions, | ||
validators: validators | ||
export default { | ||
assertOptions, | ||
validators | ||
}; |
'use strict'; | ||
module.exports = FormData; | ||
export default FormData; |
'use strict'; | ||
var AxiosURLSearchParams = require('../../../helpers/AxiosURLSearchParams'); | ||
module.exports = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams; | ||
import AxiosURLSearchParams from '../../../helpers/AxiosURLSearchParams.js'; | ||
export default typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams; |
@@ -1,11 +0,43 @@ | ||
'use strict'; | ||
import URLSearchParams from './classes/URLSearchParams.js' | ||
import FormData from './classes/FormData.js' | ||
module.exports = { | ||
/** | ||
* Determine if we're running in a standard browser environment | ||
* | ||
* This allows axios to run in a web worker, and react-native. | ||
* Both environments support XMLHttpRequest, but not fully standard globals. | ||
* | ||
* web workers: | ||
* typeof window -> undefined | ||
* typeof document -> undefined | ||
* | ||
* react-native: | ||
* navigator.product -> 'ReactNative' | ||
* nativescript | ||
* navigator.product -> 'NativeScript' or 'NS' | ||
* | ||
* @returns {boolean} | ||
*/ | ||
const isStandardBrowserEnv = (() => { | ||
let product; | ||
if (typeof navigator !== 'undefined' && ( | ||
(product = navigator.product) === 'ReactNative' || | ||
product === 'NativeScript' || | ||
product === 'NS') | ||
) { | ||
return false; | ||
} | ||
return typeof window !== 'undefined' && typeof document !== 'undefined'; | ||
})(); | ||
export default { | ||
isBrowser: true, | ||
classes: { | ||
URLSearchParams: require('./classes/URLSearchParams'), | ||
FormData: require('./classes/FormData'), | ||
Blob: Blob | ||
URLSearchParams, | ||
FormData, | ||
Blob | ||
}, | ||
protocols: ['http', 'https', 'file', 'blob', 'url'] | ||
isStandardBrowserEnv, | ||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'] | ||
}; |
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
import platform from './node/index.js'; | ||
module.exports = require('./node/'); | ||
export {platform as default} |
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
import FormData from 'form-data'; | ||
module.exports = require('form-data'); | ||
export default FormData; |
'use strict'; | ||
var url = require('url'); | ||
module.exports = url.URLSearchParams; | ||
import url from 'url'; | ||
export default url.URLSearchParams; |
@@ -1,8 +0,9 @@ | ||
'use strict'; | ||
import URLSearchParams from './classes/URLSearchParams.js' | ||
import FormData from './classes/FormData.js' | ||
module.exports = { | ||
export default { | ||
isNode: true, | ||
classes: { | ||
URLSearchParams: require('./classes/URLSearchParams'), | ||
FormData: require('./classes/FormData'), | ||
URLSearchParams, | ||
FormData, | ||
Blob: typeof Blob !== 'undefined' && Blob || null | ||
@@ -9,0 +10,0 @@ }, |
482
lib/utils.js
'use strict'; | ||
var bind = require('./helpers/bind'); | ||
import bind from './helpers/bind.js'; | ||
// utils is a library of generic helper functions non-specific to axios | ||
var toString = Object.prototype.toString; | ||
const {toString} = Object.prototype; | ||
const {getPrototypeOf} = Object; | ||
// eslint-disable-next-line func-names | ||
var kindOf = (function(cache) { | ||
// eslint-disable-next-line func-names | ||
return function(thing) { | ||
var str = toString.call(thing); | ||
const kindOf = (cache => thing => { | ||
const str = toString.call(thing); | ||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | ||
}; | ||
})(Object.create(null)); | ||
function kindOfTest(type) { | ||
const kindOfTest = (type) => { | ||
type = type.toLowerCase(); | ||
return function isKindOf(thing) { | ||
return kindOf(thing) === type; | ||
}; | ||
return (thing) => kindOf(thing) === type | ||
} | ||
const typeOfTest = type => thing => typeof thing === type; | ||
/** | ||
@@ -29,7 +26,6 @@ * Determine if a value is an Array | ||
* @param {Object} val The value to test | ||
* | ||
* @returns {boolean} True if value is an Array, otherwise false | ||
*/ | ||
function isArray(val) { | ||
return Array.isArray(val); | ||
} | ||
const {isArray} = Array; | ||
@@ -39,8 +35,7 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
*/ | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
} | ||
const isUndefined = typeOfTest('undefined'); | ||
@@ -50,3 +45,4 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Buffer, otherwise false | ||
@@ -56,3 +52,3 @@ */ | ||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) | ||
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); | ||
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val); | ||
} | ||
@@ -63,7 +59,7 @@ | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
var isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
const isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
@@ -74,7 +70,8 @@ | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBufferView(val) { | ||
var result; | ||
let result; | ||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { | ||
@@ -91,18 +88,24 @@ result = ArrayBuffer.isView(val); | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a String, otherwise false | ||
*/ | ||
function isString(val) { | ||
return typeof val === 'string'; | ||
} | ||
const isString = typeOfTest('string'); | ||
/** | ||
* Determine if a value is a Function | ||
* | ||
* @param {*} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
const isFunction = typeOfTest('function'); | ||
/** | ||
* Determine if a value is a Number | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Number, otherwise false | ||
*/ | ||
function isNumber(val) { | ||
return typeof val === 'number'; | ||
} | ||
const isNumber = typeOfTest('number'); | ||
@@ -112,16 +115,24 @@ /** | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
*/ | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
} | ||
const isObject = (thing) => thing !== null && typeof thing === 'object'; | ||
/** | ||
* Determine if a value is a Boolean | ||
* | ||
* @param {*} thing The value to test | ||
* @returns {boolean} True if value is a Boolean, otherwise false | ||
*/ | ||
const isBoolean = thing => thing === true || thing === false; | ||
/** | ||
* Determine if a value is a plain Object | ||
* | ||
* @param {Object} val The value to test | ||
* @return {boolean} True if value is a plain Object, otherwise false | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a plain Object, otherwise false | ||
*/ | ||
function isPlainObject(val) { | ||
const isPlainObject = (val) => { | ||
if (kindOf(val) !== 'object') { | ||
@@ -131,3 +142,3 @@ return false; | ||
var prototype = Object.getPrototypeOf(val); | ||
const prototype = getPrototypeOf(val); | ||
return prototype === null || prototype === Object.prototype; | ||
@@ -139,7 +150,7 @@ } | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
var isDate = kindOfTest('Date'); | ||
const isDate = kindOfTest('Date'); | ||
@@ -149,7 +160,7 @@ /** | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
var isFile = kindOfTest('File'); | ||
const isFile = kindOfTest('File'); | ||
@@ -159,7 +170,7 @@ /** | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
var isBlob = kindOfTest('Blob'); | ||
const isBlob = kindOfTest('Blob'); | ||
@@ -169,27 +180,16 @@ /** | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
var isFileList = kindOfTest('FileList'); | ||
const isFileList = kindOfTest('FileList'); | ||
/** | ||
* Determine if a value is a Function | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
function isFunction(val) { | ||
return toString.call(val) === '[object Function]'; | ||
} | ||
/** | ||
* Determine if a value is a Stream | ||
* | ||
* @param {Object} val The value to test | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a Stream, otherwise false | ||
*/ | ||
function isStream(val) { | ||
return isObject(val) && isFunction(val.pipe); | ||
} | ||
const isStream = (val) => isObject(val) && isFunction(val.pipe); | ||
@@ -199,7 +199,8 @@ /** | ||
* | ||
* @param {Object} thing The value to test | ||
* @param {*} thing The value to test | ||
* | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
function isFormData(thing) { | ||
var pattern = '[object FormData]'; | ||
const isFormData = (thing) => { | ||
const pattern = '[object FormData]'; | ||
return thing && ( | ||
@@ -214,7 +215,8 @@ (typeof FormData === 'function' && thing instanceof FormData) || | ||
* Determine if a value is a URLSearchParams object | ||
* @function | ||
* @param {Object} val The value to test | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false | ||
*/ | ||
var isURLSearchParams = kindOfTest('URLSearchParams'); | ||
const isURLSearchParams = kindOfTest('URLSearchParams'); | ||
@@ -225,37 +227,9 @@ /** | ||
* @param {String} str The String to trim | ||
* | ||
* @returns {String} The String freed of excess whitespace | ||
*/ | ||
function trim(str) { | ||
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
} | ||
const trim = (str) => str.trim ? | ||
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
/** | ||
* Determine if we're running in a standard browser environment | ||
* | ||
* This allows axios to run in a web worker, and react-native. | ||
* Both environments support XMLHttpRequest, but not fully standard globals. | ||
* | ||
* web workers: | ||
* typeof window -> undefined | ||
* typeof document -> undefined | ||
* | ||
* react-native: | ||
* navigator.product -> 'ReactNative' | ||
* nativescript | ||
* navigator.product -> 'NativeScript' or 'NS' | ||
*/ | ||
function isStandardBrowserEnv() { | ||
var product; | ||
if (typeof navigator !== 'undefined' && ( | ||
(product = navigator.product) === 'ReactNative' || | ||
product === 'NativeScript' || | ||
product === 'NS') | ||
) { | ||
return false; | ||
} | ||
return typeof window !== 'undefined' && typeof document !== 'undefined'; | ||
} | ||
/** | ||
* Iterate over an Array or an Object invoking a function for each item. | ||
@@ -271,4 +245,7 @@ * | ||
* @param {Function} fn The callback to invoke for each item | ||
* | ||
* @param {Boolean} [allOwnKeys = false] | ||
* @returns {void} | ||
*/ | ||
function forEach(obj, fn) { | ||
function forEach(obj, fn, {allOwnKeys = false} = {}) { | ||
// Don't bother if no value provided | ||
@@ -279,2 +256,5 @@ if (obj === null || typeof obj === 'undefined') { | ||
let i; | ||
let l; | ||
// Force an array if not already something iterable | ||
@@ -288,3 +268,3 @@ if (typeof obj !== 'object') { | ||
// Iterate over array values | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
for (i = 0, l = obj.length; i < l; i++) { | ||
fn.call(null, obj[i], i, obj); | ||
@@ -294,6 +274,9 @@ } | ||
// Iterate over object keys | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj); | ||
const len = keys.length; | ||
let key; | ||
for (i = 0; i < len; i++) { | ||
key = keys[i]; | ||
fn.call(null, obj[key], key, obj); | ||
} | ||
@@ -318,7 +301,8 @@ } | ||
* @param {Object} obj1 Object to merge | ||
* | ||
* @returns {Object} Result of all merge properties | ||
*/ | ||
function merge(/* obj1, obj2, obj3, ... */) { | ||
var result = {}; | ||
function assignValue(val, key) { | ||
const result = {}; | ||
const assignValue = (val, key) => { | ||
if (isPlainObject(result[key]) && isPlainObject(val)) { | ||
@@ -335,4 +319,4 @@ result[key] = merge(result[key], val); | ||
for (var i = 0, l = arguments.length; i < l; i++) { | ||
forEach(arguments[i], assignValue); | ||
for (let i = 0, l = arguments.length; i < l; i++) { | ||
arguments[i] && forEach(arguments[i], assignValue); | ||
} | ||
@@ -348,7 +332,9 @@ return result; | ||
* @param {Object} thisArg The object to bind function to | ||
* @return {Object} The resulting value of object a | ||
* | ||
* @param {Boolean} [allOwnKeys] | ||
* @returns {Object} The resulting value of object a | ||
*/ | ||
function extend(a, b, thisArg) { | ||
forEach(b, function assignValue(val, key) { | ||
if (thisArg && typeof val === 'function') { | ||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => { | ||
forEach(b, (val, key) => { | ||
if (thisArg && isFunction(val)) { | ||
a[key] = bind(val, thisArg); | ||
@@ -358,3 +344,3 @@ } else { | ||
} | ||
}); | ||
}, {allOwnKeys}); | ||
return a; | ||
@@ -367,5 +353,6 @@ } | ||
* @param {string} content with BOM | ||
* @return {string} content value without BOM | ||
* | ||
* @returns {string} content value without BOM | ||
*/ | ||
function stripBOM(content) { | ||
const stripBOM = (content) => { | ||
if (content.charCodeAt(0) === 0xFEFF) { | ||
@@ -383,7 +370,11 @@ content = content.slice(1); | ||
* @param {object} [descriptors] | ||
* | ||
* @returns {void} | ||
*/ | ||
function inherits(constructor, superConstructor, props, descriptors) { | ||
const inherits = (constructor, superConstructor, props, descriptors) => { | ||
constructor.prototype = Object.create(superConstructor.prototype, descriptors); | ||
constructor.prototype.constructor = constructor; | ||
Object.defineProperty(constructor, 'super', { | ||
value: superConstructor.prototype | ||
}); | ||
props && Object.assign(constructor.prototype, props); | ||
@@ -398,11 +389,11 @@ } | ||
* @param {Function} [propFilter] | ||
* | ||
* @returns {Object} | ||
*/ | ||
const toFlatObject = (sourceObj, destObj, filter, propFilter) => { | ||
let props; | ||
let i; | ||
let prop; | ||
const merged = {}; | ||
function toFlatObject(sourceObj, destObj, filter, propFilter) { | ||
var props; | ||
var i; | ||
var prop; | ||
var merged = {}; | ||
destObj = destObj || {}; | ||
@@ -422,3 +413,3 @@ // eslint-disable-next-line no-eq-null,eqeqeq | ||
} | ||
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj); | ||
sourceObj = filter !== false && getPrototypeOf(sourceObj); | ||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | ||
@@ -429,10 +420,12 @@ | ||
/* | ||
* determines whether a string ends with the characters of a specified string | ||
/** | ||
* Determines whether a string ends with the characters of a specified string | ||
* | ||
* @param {String} str | ||
* @param {String} searchString | ||
* @param {Number} [position= 0] | ||
* | ||
* @returns {boolean} | ||
*/ | ||
function endsWith(str, searchString, position) { | ||
const endsWith = (str, searchString, position) => { | ||
str = String(str); | ||
@@ -443,3 +436,3 @@ if (position === undefined || position > str.length) { | ||
position -= searchString.length; | ||
var lastIndex = str.indexOf(searchString, position); | ||
const lastIndex = str.indexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
@@ -451,11 +444,13 @@ } | ||
* Returns new array from array like object or null if failed | ||
* | ||
* @param {*} [thing] | ||
* | ||
* @returns {?Array} | ||
*/ | ||
function toArray(thing) { | ||
const toArray = (thing) => { | ||
if (!thing) return null; | ||
if (isArray(thing)) return thing; | ||
var i = thing.length; | ||
let i = thing.length; | ||
if (!isNumber(i)) return null; | ||
var arr = new Array(i); | ||
const arr = new Array(i); | ||
while (i-- > 0) { | ||
@@ -467,19 +462,35 @@ arr[i] = thing[i]; | ||
/** | ||
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the | ||
* thing passed in is an instance of Uint8Array | ||
* | ||
* @param {TypedArray} | ||
* | ||
* @returns {Array} | ||
*/ | ||
// eslint-disable-next-line func-names | ||
var isTypedArray = (function(TypedArray) { | ||
const isTypedArray = (TypedArray => { | ||
// eslint-disable-next-line func-names | ||
return function(thing) { | ||
return thing => { | ||
return TypedArray && thing instanceof TypedArray; | ||
}; | ||
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array)); | ||
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array)); | ||
function forEachEntry(obj, fn) { | ||
var generator = obj && obj[Symbol.iterator]; | ||
/** | ||
* For each entry in the object, call the function with the key and value. | ||
* | ||
* @param {Object<any, any>} obj - The object to iterate over. | ||
* @param {Function} fn - The function to call for each entry. | ||
* | ||
* @returns {void} | ||
*/ | ||
const forEachEntry = (obj, fn) => { | ||
const generator = obj && obj[Symbol.iterator]; | ||
var iterator = generator.call(obj); | ||
const iterator = generator.call(obj); | ||
var result; | ||
let result; | ||
while ((result = iterator.next()) && !result.done) { | ||
var pair = result.value; | ||
const pair = result.value; | ||
fn.call(obj, pair[0], pair[1]); | ||
@@ -489,5 +500,13 @@ } | ||
function matchAll(regExp, str) { | ||
var matches; | ||
var arr = []; | ||
/** | ||
* It takes a regular expression and a string, and returns an array of all the matches | ||
* | ||
* @param {string} regExp - The regular expression to match against. | ||
* @param {string} str - The string to search. | ||
* | ||
* @returns {Array<boolean>} | ||
*/ | ||
const matchAll = (regExp, str) => { | ||
let matches; | ||
const arr = []; | ||
@@ -501,45 +520,128 @@ while ((matches = regExp.exec(str)) !== null) { | ||
var isHTMLForm = kindOfTest('HTMLFormElement'); | ||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ | ||
const isHTMLForm = kindOfTest('HTMLFormElement'); | ||
var hasOwnProperty = (function resolver(_hasOwnProperty) { | ||
return function(obj, prop) { | ||
return _hasOwnProperty.call(obj, prop); | ||
}; | ||
})(Object.prototype.hasOwnProperty); | ||
const toCamelCase = str => { | ||
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g, | ||
function replacer(m, p1, p2) { | ||
return p1.toUpperCase() + p2; | ||
} | ||
); | ||
}; | ||
module.exports = { | ||
isArray: isArray, | ||
isArrayBuffer: isArrayBuffer, | ||
isBuffer: isBuffer, | ||
isFormData: isFormData, | ||
isArrayBufferView: isArrayBufferView, | ||
isString: isString, | ||
isNumber: isNumber, | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isUndefined: isUndefined, | ||
isDate: isDate, | ||
isFile: isFile, | ||
isBlob: isBlob, | ||
isFunction: isFunction, | ||
isStream: isStream, | ||
isURLSearchParams: isURLSearchParams, | ||
isStandardBrowserEnv: isStandardBrowserEnv, | ||
forEach: forEach, | ||
merge: merge, | ||
extend: extend, | ||
trim: trim, | ||
stripBOM: stripBOM, | ||
inherits: inherits, | ||
toFlatObject: toFlatObject, | ||
kindOf: kindOf, | ||
kindOfTest: kindOfTest, | ||
endsWith: endsWith, | ||
toArray: toArray, | ||
isTypedArray: isTypedArray, | ||
isFileList: isFileList, | ||
forEachEntry: forEachEntry, | ||
matchAll: matchAll, | ||
isHTMLForm: isHTMLForm, | ||
hasOwnProperty: hasOwnProperty | ||
/* Creating a function that will check if an object has a property. */ | ||
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype); | ||
/** | ||
* Determine if a value is a RegExp object | ||
* | ||
* @param {*} val The value to test | ||
* | ||
* @returns {boolean} True if value is a RegExp object, otherwise false | ||
*/ | ||
const isRegExp = kindOfTest('RegExp'); | ||
const reduceDescriptors = (obj, reducer) => { | ||
const descriptors = Object.getOwnPropertyDescriptors(obj); | ||
const reducedDescriptors = {}; | ||
forEach(descriptors, (descriptor, name) => { | ||
if (reducer(descriptor, name, obj) !== false) { | ||
reducedDescriptors[name] = descriptor; | ||
} | ||
}); | ||
Object.defineProperties(obj, reducedDescriptors); | ||
} | ||
/** | ||
* Makes all methods read-only | ||
* @param {Object} obj | ||
*/ | ||
const freezeMethods = (obj) => { | ||
reduceDescriptors(obj, (descriptor, name) => { | ||
const value = obj[name]; | ||
if (!isFunction(value)) return; | ||
descriptor.enumerable = false; | ||
if ('writable' in descriptor) { | ||
descriptor.writable = false; | ||
return; | ||
} | ||
if (!descriptor.set) { | ||
descriptor.set = () => { | ||
throw Error('Can not read-only method \'' + name + '\''); | ||
}; | ||
} | ||
}); | ||
} | ||
const toObjectSet = (arrayOrString, delimiter) => { | ||
const obj = {}; | ||
const define = (arr) => { | ||
arr.forEach(value => { | ||
obj[value] = true; | ||
}); | ||
} | ||
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)); | ||
return obj; | ||
} | ||
const noop = () => {} | ||
const toFiniteNumber = (value, defaultValue) => { | ||
value = +value; | ||
return Number.isFinite(value) ? value : defaultValue; | ||
} | ||
export default { | ||
isArray, | ||
isArrayBuffer, | ||
isBuffer, | ||
isFormData, | ||
isArrayBufferView, | ||
isString, | ||
isNumber, | ||
isBoolean, | ||
isObject, | ||
isPlainObject, | ||
isUndefined, | ||
isDate, | ||
isFile, | ||
isBlob, | ||
isRegExp, | ||
isFunction, | ||
isStream, | ||
isURLSearchParams, | ||
isTypedArray, | ||
isFileList, | ||
forEach, | ||
merge, | ||
extend, | ||
trim, | ||
stripBOM, | ||
inherits, | ||
toFlatObject, | ||
kindOf, | ||
kindOfTest, | ||
endsWith, | ||
toArray, | ||
forEachEntry, | ||
matchAll, | ||
isHTMLForm, | ||
hasOwnProperty, | ||
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection | ||
reduceDescriptors, | ||
freezeMethods, | ||
toObjectSet, | ||
toCamelCase, | ||
noop, | ||
toFiniteNumber | ||
}; |
{ | ||
"name": "axios", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0", | ||
"description": "Promise based HTTP client for the browser and node.js", | ||
"main": "index.js", | ||
"exports": { | ||
".": { | ||
"browser": { | ||
"require": "./index.js", | ||
"default": "./index.js" | ||
}, | ||
"default": { | ||
"require": "./dist/node/axios.cjs", | ||
"default": "./index.js" | ||
} | ||
} | ||
}, | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "node bin/ssl_hotfix.js grunt test && node bin/ssl_hotfix.js dtslint", | ||
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint", | ||
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js", | ||
"test:dtslint": "node bin/ssl_hotfix.js dtslint", | ||
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit", | ||
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run", | ||
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs", | ||
"start": "node ./sandbox/server.js", | ||
"preversion": "grunt version && npm test", | ||
"build": "cross-env NODE_ENV=production grunt build", | ||
"preversion": "gulp version && npm test", | ||
"version": "npm run build && git add dist && git add package.json", | ||
"prepublishOnly": "npm test", | ||
"postpublish": "git push && git push --tags", | ||
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m", | ||
"examples": "node ./examples/server.js", | ||
@@ -34,3 +55,4 @@ "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"devDependencies": { | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@babel/preset-env": "^7.18.2", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
@@ -44,16 +66,11 @@ "@rollup/plugin-json": "^4.1.0", | ||
"cross-env": "^7.0.3", | ||
"dev-null": "^0.1.1", | ||
"dtslint": "^4.2.1", | ||
"es6-promise": "^4.2.8", | ||
"eslint": "^8.17.0", | ||
"express": "^4.18.1", | ||
"formidable": "^2.0.1", | ||
"grunt": "^1.4.1", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.4.3", | ||
"grunt-contrib-clean": "^2.0.0", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"grunt-eslint": "^24.0.0", | ||
"grunt-karma": "^4.0.2", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-shell": "^3.0.1", | ||
"grunt-webpack": "^5.0.0", | ||
"fs-extra": "^10.1.0", | ||
"get-stream": "^3.0.0", | ||
"gulp": "^4.0.2", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
@@ -66,2 +83,3 @@ "jasmine-core": "^2.4.1", | ||
"karma-jasmine-ajax": "^0.1.13", | ||
"karma-rollup-preprocessor": "^7.0.8", | ||
"karma-safari-launcher": "^1.0.0", | ||
@@ -71,15 +89,14 @@ "karma-sauce-launcher": "^4.3.6", | ||
"karma-sourcemap-loader": "^0.3.8", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^5.1.0", | ||
"minimist": "^1.2.6", | ||
"mocha": "^8.2.1", | ||
"mocha": "^10.0.0", | ||
"multer": "^1.4.4", | ||
"rollup": "^2.67.0", | ||
"rollup-plugin-auto-external": "^2.0.0", | ||
"rollup-plugin-bundle-size": "^1.0.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"sinon": "^4.5.0", | ||
"stream-throttle": "^0.1.3", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"typescript": "^4.6.3", | ||
"url-search-params": "^0.10.0", | ||
"webpack": "^4.44.2", | ||
"webpack-dev-server": "^3.11.0" | ||
"url-search-params": "^0.10.0" | ||
}, | ||
@@ -103,3 +120,19 @@ "browser": { | ||
} | ||
], | ||
"contributors": [ | ||
"Matt Zabriskie (https://github.com/mzabriskie)", | ||
"Nick Uraltsev (https://github.com/nickuraltsev)", | ||
"Jay (https://github.com/jasonsaayman)", | ||
"Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)", | ||
"Emily Morehouse (https://github.com/emilyemorehouse)", | ||
"Rubรฉn Norte (https://github.com/rubennorte)", | ||
"Justin Beckwith (https://github.com/JustinBeckwith)", | ||
"Martti Laine (https://github.com/codeclown)", | ||
"Xianming Zhong (https://github.com/chinesedfan)", | ||
"Rikki Gibson (https://github.com/RikkiGibson)", | ||
"Remco Haszing (https://github.com/remcohaszing)", | ||
"Yasu Flores (https://github.com/yasuf)", | ||
"Ben Carp (https://github.com/carpben)", | ||
"Daniel Lopretto (https://github.com/timemachine3030)" | ||
] | ||
} | ||
} |
107
README.md
@@ -1,7 +0,20 @@ | ||
# axios | ||
<h1 align="center"> | ||
<b> | ||
<a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br> | ||
</b> | ||
</h1> | ||
<p align="center">Promise based HTTP client for the browser and node.js</p> | ||
<p align="center"> | ||
<a href="https://axios-http.com/"><b>Website</b></a> โข | ||
<a href="https://axios-http.com/docs/intro"><b>Documentation</b></a> | ||
</p> | ||
<div align="center"> | ||
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios) | ||
![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios) | ||
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios) | ||
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) | ||
@@ -15,6 +28,4 @@ [![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios) | ||
Promise based HTTP client for the browser and node.js | ||
> New axios docs website: [click here](https://axios-http.com/) | ||
</div> | ||
## Table of Contents | ||
@@ -46,8 +57,8 @@ | ||
- [Query string](#query-string-older-browsers) | ||
- [๐ Automatic serialization](#-automatic-serialization-to-urlsearchparams) | ||
- [Using multipart/form-data format](#using-multipartform-data-format) | ||
- [๐ Automatic serialization](#-automatic-serialization-to-urlsearchparams) | ||
- [Using multipart/form-data format](#using-multipartform-data-format) | ||
- [FormData](#formdata) | ||
- [๐ Automatic serialization](#-automatic-serialization-to-formdata) | ||
- [๐ Automatic serialization](#-automatic-serialization-to-formdata) | ||
- [Files Posting](#files-posting) | ||
- [HTML Form Posting](#html-form-posting-browser) | ||
- [HTML Form Posting](#-html-form-posting-browser) | ||
- [Semver](#semver) | ||
@@ -144,3 +155,3 @@ - [Promises](#promises) | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
@@ -161,5 +172,5 @@ }); | ||
}) | ||
.then(function () { | ||
.finally(function () { | ||
// always executed | ||
}); | ||
}); | ||
@@ -177,3 +188,3 @@ // Want to use async/await? Add the `async` keyword to your outer function/method. | ||
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> **Note** `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
> Explorer and older browsers, so use with caution. | ||
@@ -362,3 +373,3 @@ | ||
}, | ||
// syntax alternative to send data into the body | ||
@@ -471,3 +482,3 @@ // method post | ||
// `Proxy-Authorization` custom headers you have set using `headers`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
// If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
proxy: { | ||
@@ -491,4 +502,4 @@ protocol: 'https', | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// `decompress` indicates whether or not the response body should be decompressed | ||
// automatically. If set to `true` will also remove the 'content-encoding' header | ||
// from the responses objects of all decompressed responses | ||
@@ -515,3 +526,3 @@ // - Node only (XHR cannot turn off decompression) | ||
forcedJSONParsing: true, | ||
// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
@@ -527,5 +538,5 @@ clarifyTimeoutError: false, | ||
formSerializer: { | ||
visitor: (value, key, path, helpers)=> {}; // custom visitor funaction to serrialize form values | ||
visitor: (value, key, path, helpers) => {}; // custom visitor funaction to serrialize form values | ||
dots: boolean; // use dots instead of brackets format | ||
metaTokens: boolean; // keep special endings like {} in parameter key | ||
metaTokens: boolean; // keep special endings like {} in parameter key | ||
indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes | ||
@@ -678,3 +689,3 @@ } | ||
When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag | ||
@@ -690,3 +701,3 @@ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution. | ||
If you want to execute a particular interceptor based on a runtime check, | ||
If you want to execute a particular interceptor based on a runtime check, | ||
you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return | ||
@@ -719,3 +730,3 @@ of `runWhen` is `false`. The function will be called with the config | ||
- once caught, another following fulfill-interceptor is called again (just like in a promise chain). | ||
Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code. | ||
@@ -835,3 +846,3 @@ | ||
> Note: you can cancel several requests with the same cancel token/abort controller. | ||
> **Note:** you can cancel several requests with the same cancel token/abort controller. | ||
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make a real request. | ||
@@ -889,3 +900,3 @@ | ||
> NOTE: | ||
> **Note** | ||
> The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case. | ||
@@ -897,3 +908,3 @@ | ||
``` | ||
```js | ||
const data = { | ||
@@ -911,3 +922,3 @@ x: 1, | ||
The server will handle it as | ||
The server will handle it as | ||
@@ -933,5 +944,5 @@ ```js | ||
var app = express(); | ||
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies | ||
app.post('/', function (req, res, next) { | ||
@@ -949,3 +960,3 @@ // echo body as JSON | ||
To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. | ||
To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. | ||
Setting the `Content-Type` header is not required as Axios guesses it based on the payload type. | ||
@@ -959,3 +970,3 @@ | ||
``` | ||
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
@@ -965,3 +976,3 @@ | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
@@ -977,3 +988,3 @@ form.append('my_field', 'my value'); | ||
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
header is set to `multipart/form-data`. | ||
@@ -990,3 +1001,3 @@ | ||
} | ||
}).then(({data})=> console.log(data)); | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
@@ -1000,3 +1011,3 @@ | ||
```js | ||
const axios= require('axios'); | ||
const axios = require('axios'); | ||
var FormData = require('form-data'); | ||
@@ -1008,3 +1019,3 @@ | ||
} | ||
}).then(({data})=> console.log(data)); | ||
}).then(({data}) => console.log(data)); | ||
``` | ||
@@ -1015,5 +1026,5 @@ | ||
- `{}` - serialize the value with JSON.stringify | ||
- `[]` - unwrap the array-like object as separate fields with the same key | ||
- `[]` - unwrap the array-like object as separate fields with the same key | ||
> NOTE: | ||
> **Note** | ||
> unwrap/expand operation will be used by default on arrays and FileList objects | ||
@@ -1028,3 +1039,3 @@ | ||
- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. | ||
- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. | ||
The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. | ||
@@ -1034,6 +1045,6 @@ | ||
- `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) | ||
- `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) | ||
- `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) | ||
- `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) | ||
Let's say we have an object like this one: | ||
@@ -1054,3 +1065,3 @@ | ||
```js | ||
const formData= new FormData(); | ||
const formData = new FormData(); | ||
formData.append('x', '1'); | ||
@@ -1075,3 +1086,3 @@ formData.append('arr[]', '1'); | ||
You can easily sumbit a single file | ||
You can easily submit a single file: | ||
@@ -1081,11 +1092,11 @@ ```js | ||
'myVar' : 'foo', | ||
'file': document.querySelector('#fileInput').files[0] | ||
'file': document.querySelector('#fileInput').files[0] | ||
}); | ||
``` | ||
or multiple files as `multipart/form-data`. | ||
or multiple files as `multipart/form-data`: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', { | ||
'files[]': document.querySelector('#fileInput').files | ||
'files[]': document.querySelector('#fileInput').files | ||
}); | ||
@@ -1193,3 +1204,3 @@ ``` | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js) | ||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) | ||
@@ -1196,0 +1207,0 @@ |
@@ -5,2 +5,5 @@ import resolve from '@rollup/plugin-node-resolve'; | ||
import json from '@rollup/plugin-json'; | ||
import { babel } from '@rollup/plugin-babel'; | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
import bundleSize from 'rollup-plugin-bundle-size' | ||
@@ -12,3 +15,3 @@ const lib = require("./package.json"); | ||
const buildConfig = (config) => { | ||
const buildConfig = ({es5, browser = true, minifiedVersion = true, ...config}) => { | ||
@@ -24,5 +27,10 @@ const build = ({minified}) => ({ | ||
json(), | ||
resolve({browser: true}), | ||
resolve({browser}), | ||
commonjs(), | ||
minified && terser(), | ||
minified && bundleSize(), | ||
...(es5 ? [babel({ | ||
babelHelpers: 'bundled', | ||
presets: ['@babel/preset-env'] | ||
})] : []), | ||
...(config.plugins || []), | ||
@@ -32,6 +40,11 @@ ] | ||
return [ | ||
const configs = [ | ||
build({minified: false}), | ||
build({minified: true}), | ||
]; | ||
if (minifiedVersion) { | ||
configs.push(build({minified: true})) | ||
} | ||
return configs; | ||
}; | ||
@@ -41,6 +54,7 @@ | ||
const year = new Date().getFullYear(); | ||
const banner = `// ${lib.name} v${lib.version} Copyright (c) ${year} ${lib.author}`; | ||
const banner = `// Axios v${lib.version} Copyright (c) ${year} ${lib.author} and contributors`; | ||
return [ | ||
...buildConfig({ | ||
es5: true, | ||
output: { | ||
@@ -63,4 +77,20 @@ file: `dist/${outputFileName}`, | ||
} | ||
}) | ||
}), | ||
// Node.js commonjs build | ||
{ | ||
input, | ||
output: { | ||
file: `dist/node/${name}.cjs`, | ||
format: "cjs", | ||
preferConst: true, | ||
exports: "default", | ||
banner | ||
}, | ||
plugins: [ | ||
autoExternal(), | ||
resolve(), | ||
commonjs() | ||
] | ||
} | ||
] | ||
}; |
# Reporting a Vulnerability | ||
If you discover a security vulnerability within axios, please submit a report via [huntr.dev](https://huntr.dev/bounties/?target=https%3A%2F%2Fgithub.com%2Faxios%2Faxios). Bounties and CVEs are automatically managed and allocated via the platform. | ||
If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there. | ||
All security vulnerabilities will be promptly addressed. | ||
Thank you for improving the security of axios. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1297906
43
77
12458
0
1191
Yes
17
5