Comparing version 0.26.1 to 0.27.0
# Changelog | ||
### 0.27.0 (April 19, 2022) | ||
Breaking changes: | ||
- New toFormData helper function that allows the implementor to pass an object and allow axios to convert it to FormData ([#3757](https://github.com/axios/axios/pull/3757)) | ||
- Removed functionality that removed the the `Content-Type` request header when passing FormData ([#3785](https://github.com/axios/axios/pull/3785)) | ||
- **(*)** Refactored error handling implementing AxiosError as a constructor, this is a large change to error handling on the whole ([#3645](https://github.com/axios/axios/pull/3645)) | ||
- Separated responsibility for FormData instantiation between `transformRequest` and `toFormData` ([#4470](https://github.com/axios/axios/pull/4470)) | ||
- **(*)** Improved and fixed multiple issues with FormData support ([#4448](https://github.com/axios/axios/pull/4448)) | ||
QOL and DevX improvements: | ||
- Added a multipart/form-data testing playground allowing contributors to debug changes easily ([#4465](https://github.com/axios/axios/pull/4465)) | ||
Fixes and Functionality: | ||
- Refactored project file structure to avoid circular imports ([#4515](https://github.com/axios/axios/pull/4516)) & ([#4516](https://github.com/axios/axios/pull/4516)) | ||
- Bumped follow-redirects to ^1.14.9 ([#4562](https://github.com/axios/axios/pull/4562)) | ||
Internal and Tests: | ||
- Updated dev dependencies to latest version | ||
Documentation: | ||
- Fixing incorrect link in changelog ([#4551](https://github.com/axios/axios/pull/4551)) | ||
Notes: | ||
- **(*)** Please read these pull requests before updating, these changes are very impactful and far reaching. | ||
### 0.26.1 (March 9, 2022) | ||
Fixes and Functionality: | ||
- Refactored project file structure to avoid circular imports ([##4220](https://github.com/axios/axios/pull/#4220)) | ||
- Refactored project file structure to avoid circular imports ([#4220](https://github.com/axios/axios/pull/4220)) | ||
@@ -14,3 +39,3 @@ ### 0.26.0 (February 13, 2022) | ||
- Fix/remove url required ([#4426](https://github.com/axios/axios/pull/4426)) | ||
- Update follow-redirects dependency due to Vurnerbility ([#4462](https://github.com/axios/axios/pull/4462)) | ||
- Update follow-redirects dependency due to Vulnerability ([#4462](https://github.com/axios/axios/pull/4462)) | ||
- Bump karma from 6.3.11 to 6.3.14 ([#4461](https://github.com/axios/axios/pull/4461)) | ||
@@ -23,3 +48,3 @@ - Bump follow-redirects from 1.14.7 to 1.14.8 ([#4473](https://github.com/axios/axios/pull/4473)) | ||
- Fixing maxBodyLength enforcement ([#3786](https://github.com/axios/axios/pull/3786)) | ||
- Don't rely on strict mode behaviour for arguments ([#3470](https://github.com/axios/axios/pull/3470)) | ||
- Don't rely on strict mode behavior for arguments ([#3470](https://github.com/axios/axios/pull/3470)) | ||
- Adding error handling when missing url ([#3791](https://github.com/axios/axios/pull/3791)) | ||
@@ -41,3 +66,3 @@ - Update isAbsoluteURL.js removing escaping of non-special characters ([#3809](https://github.com/axios/axios/pull/3809)) | ||
Internal and Tests: | ||
- Adding axios-test-instance to ecosystem ([#3786](https://github.com/axios/axios/pull/3786)) | ||
- Adding axios-test-instance to ecosystem ([#3496](https://github.com/axios/axios/pull/3496)) | ||
- Optimize the logic of isAxiosError ([#3546](https://github.com/axios/axios/pull/3546)) | ||
@@ -47,5 +72,4 @@ - Add tests and documentation to display how multiple inceptors work ([#3564](https://github.com/axios/axios/pull/3564)) | ||
Documentation: | ||
- Fixing changelog to show corrext pull request ([#4219](https://github.com/axios/axios/pull/4219)) | ||
- Fixing changelog to show correct pull request ([#4219](https://github.com/axios/axios/pull/4219)) | ||
- Update upgrade guide for https proxy setting ([#3604](https://github.com/axios/axios/pull/3604)) | ||
@@ -141,3 +165,3 @@ | ||
Fixes and Functionality: | ||
- Fixing JSON transform when data is stringified. Providing backward compatability and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020)) | ||
- Fixing JSON transform when data is stringified. Providing backward compatibility and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020)) | ||
@@ -177,5 +201,5 @@ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: | ||
- Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401)) | ||
- Updating build dev dependencies ([#3401](https://github.com/axios/axios/pull/3401)) | ||
- Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538)) | ||
- Updating follow rediect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771)) | ||
- Updating follow redirect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771)) | ||
- Updating karma sauce launcher to fix failing sauce tests ([#3712](https://github.com/axios/axios/pull/3712), [#3717](https://github.com/axios/axios/pull/3717)) | ||
@@ -190,5 +214,5 @@ - Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154)) | ||
- Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523)) | ||
- Fixing gramatical errors ([#2642](https://github.com/axios/axios/pull/2642)) | ||
- Fixing grammatical errors ([#2642](https://github.com/axios/axios/pull/2642)) | ||
- Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567)) | ||
- Moving gitpod metion ([#2637](https://github.com/axios/axios/pull/2637)) | ||
- Moving gitpod mention ([#2637](https://github.com/axios/axios/pull/2637)) | ||
- Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707)) | ||
@@ -271,3 +295,3 @@ - Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772)) | ||
- Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252)) | ||
- Fixing simple typo, existent -> existent ([#3252](https://github.com/axios/axios/pull/3252)) | ||
- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309)) | ||
@@ -274,0 +298,0 @@ |
@@ -1,2 +0,4 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=12)}([function(e,t,n){"use strict";var r=n(3),o=Object.prototype.toString;function i(e){return Array.isArray(e)}function s(e){return void 0===e}function a(e){return"[object ArrayBuffer]"===o.call(e)}function u(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function f(e){return"[object Function]"===o.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={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){return"[object FormData]"===o.call(e)},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:function(e){return"number"==typeof e},isObject:u,isPlainObject:c,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:f,isStream:function(e){return u(e)&&f(e.pipe)},isURLSearchParams:function(e){return"[object URLSearchParams]"===o.call(e)},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function e(){var t={};function n(n,r){c(t[r])&&c(n)?t[r]=e(t[r],n):c(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)l(arguments[r],n);return t},extend:function(e,t,n){return l(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){"use strict";var r=n(0),o=n(18),i=n(5),s=n(6),a={"Content-Type":"application/x-www-form-urlencoded"};function u(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,f={transitional:s,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=n(7)),c),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(u(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(u(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||f.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){f.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){f.headers[e]=r.merge(a)})),e.exports=f},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},function(e,t,n){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(e,t,n){"use strict";var r=n(0),o=n(19),i=n(20),s=n(4),a=n(21),u=n(24),c=n(25),f=n(8),l=n(6),p=n(1);e.exports=function(e){return new Promise((function(t,n){var d,h=e.data,m=e.headers,v=e.responseType;function y(){e.cancelToken&&e.cancelToken.unsubscribe(d),e.signal&&e.signal.removeEventListener("abort",d)}r.isFormData(h)&&delete m["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",x=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+x)}var w=a(e.baseURL,e.url);function E(){if(g){var r="getAllResponseHeaders"in g?u(g.getAllResponseHeaders()):null,i={data:v&&"text"!==v&&"json"!==v?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};o((function(e){t(e),y()}),(function(e){n(e),y()}),i),g=null}}if(g.open(e.method.toUpperCase(),s(w,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=E:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(E)},g.onabort=function(){g&&(n(f("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(f("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var O=(e.withCredentials||c(w))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;O&&(m[e.xsrfHeaderName]=O)}"setRequestHeader"in g&&r.forEach(m,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete m[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),v&&"json"!==v&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(d=function(e){g&&(n(!e||e&&e.type?new p("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(d),e.signal&&(e.signal.aborted?d():e.signal.addEventListener("abort",d))),h||(h=null),g.send(h)}))}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||{};var n={};function o(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 i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},function(e,t){e.exports={version:"0.26.1"}},function(e,t,n){e.exports=n(13)},function(e,t,n){"use strict";var r=n(0),o=n(3),i=n(14),s=n(10);var a=function e(t){var n=new i(t),a=o(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(2));a.Axios=i,a.Cancel=n(1),a.CancelToken=n(27),a.isCancel=n(9),a.VERSION=n(11).version,a.all=function(e){return Promise.all(e)},a.spread=n(28),a.isAxiosError=n(29),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(15),s=n(16),a=n(10),u=n(26),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&u.assertOptions(n,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var r=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var i,f=[];if(this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)})),!o){var l=[s,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(f),i=Promise.resolve(t);l.length;)i=i.then(l.shift(),l.shift());return i}for(var p=t;r.length;){var d=r.shift(),h=r.shift();try{p=d(p)}catch(e){h(e);break}}try{i=s(p)}catch(e){return Promise.reject(e)}for(;f.length;)i=i.then(f.shift(),f.shift());return i},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=f},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(17),i=n(9),s=n(2),a=n(1);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),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||s.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(0),o=n(2);e.exports=function(e,t,n){var i=this||o;return r.forEach(n,(function(n){e=n.call(i,e,t)})),e}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(8);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.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(e,t,n){"use strict";var r=n(22),o=n(23);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(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=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r=n(11).version,o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var i={};o.transitional=function(e,t,n){function o(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(o(r," has been removed"+(t?" in "+t:"")));return t&&!i[r]&&(i[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:o}},function(e,t,n){"use strict";var r=n(1);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){return r.isObject(e)&&!0===e.isAxiosError}}])})); | ||
/* axios v0.27.0 | (c) 2022 by Matt Zabriskie */ | ||
/* axios v0.26.1 | (c) 2022 by Matt Zabriskie */ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.axios=e():t.axios=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){"use strict";var n=r(4),o=Object.prototype.toString;function s(t){return Array.isArray(t)}function i(t){return void 0===t}function a(t){return"[object ArrayBuffer]"===o.call(t)}function u(t){return null!==t&&"object"==typeof t}function c(t){if("[object Object]"!==o.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function h(t){return"[object Function]"===o.call(t)}function f(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),s(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}t.exports={supportedProtocols:["http:","https:","file:"],getProtocol:function(t){return t||"http:"},isArray:s,isArrayBuffer:a,isBuffer:function(t){return null!==t&&!i(t)&&null!==t.constructor&&!i(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"[object FormData]"===o.call(t)},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&a(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:u,isPlainObject:c,isUndefined:i,isDate:function(t){return"[object Date]"===o.call(t)},isFile:function(t){return"[object File]"===o.call(t)},isBlob:function(t){return"[object Blob]"===o.call(t)},isFunction:h,isStream:function(t){return u(t)&&h(t.pipe)},isURLSearchParams:function(t){return"[object URLSearchParams]"===o.call(t)},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function t(){var e={};function r(r,n){c(e[n])&&c(r)?e[n]=t(e[n],r):c(r)?e[n]=t({},r):s(r)?e[n]=r.slice():e[n]=r}for(var n=0,o=arguments.length;n<o;n++)f(arguments[n],r);return e},extend:function(t,e,r){return f(e,(function(e,o){t[o]=r&&"function"==typeof e?n(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t},inherits:function(t,e,r,n){t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,r&&Object.assign(t.prototype,r)},toFlatObject:function(t,e,r){var n,o,s,i={};e=e||{};do{for(o=(n=Object.getOwnPropertyNames(t)).length;o-- >0;)i[s=n[o]]||(e[s]=t[s],i[s]=!0);t=Object.getPrototypeOf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e}}},function(t,e,r){"use strict";var n=r(0);function o(t,e,r,n,o){Error.call(this),this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}n.inherits(o,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 s=o.prototype,i={};["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"].forEach((function(t){i[t]={value:t}})),Object.defineProperties(o,i),Object.defineProperty(s,"isAxiosError",{value:!0}),o.from=function(t,e,r,i,a,u){var c=Object.create(s);return n.toFlatObject(t,c,(function(t){return t!==Error.prototype})),o.call(c,t.message,e,r,i,a),c.name=t.name,u&&Object.assign(c,u),c},t.exports=o},function(t,e,r){"use strict";var n=r(1);function o(t){n.call(this,null==t?"canceled":t,n.ERR_CANCELED),this.name="CanceledError"}r(0).inherits(o,n,{__CANCEL__:!0}),t.exports=o},function(t,e,r){"use strict";var n=r(0),o=r(18),s=r(1),i=r(6),a={"Content-Type":"application/x-www-form-urlencoded"};function u(t,e){!n.isUndefined(t)&&n.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var c,h={transitional:i,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=r(7)),c),transformRequest:[function(t,e){return o(e,"Accept"),o(e,"Content-Type"),n.isFormData(t)||n.isArrayBuffer(t)||n.isBuffer(t)||n.isStream(t)||n.isFile(t)||n.isBlob(t)?t:n.isArrayBufferView(t)?t.buffer:n.isURLSearchParams(t)?(u(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):n.isObject(t)||e&&"application/json"===e["Content-Type"]?(u(e,"application/json"),function(t,e,r){if(n.isString(t))try{return(e||JSON.parse)(t),n.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||h.transitional,r=e&&e.silentJSONParsing,o=e&&e.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||o&&n.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(i){if("SyntaxError"===t.name)throw s.from(t,s.ERR_BAD_RESPONSE,this,null,this.response);throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(t){h.headers[t]={}})),n.forEach(["post","put","patch"],(function(t){h.headers[t]=n.merge(a)})),t.exports=h},function(t,e,r){"use strict";t.exports=function(t,e){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return t.apply(e,r)}}},function(t,e,r){"use strict";var n=r(0);function o(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(n.isURLSearchParams(e))s=e.toString();else{var i=[];n.forEach(e,(function(t,e){null!=t&&(n.isArray(t)?e+="[]":t=[t],n.forEach(t,(function(t){n.isDate(t)?t=t.toISOString():n.isObject(t)&&(t=JSON.stringify(t)),i.push(o(e)+"="+o(t))})))})),s=i.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}},function(t,e,r){"use strict";t.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(t,e,r){"use strict";var n=r(0),o=r(19),s=r(20),i=r(5),a=r(8),u=r(23),c=r(24),h=r(25),f=r(6),l=r(1),p=r(2);t.exports=function(t){return new Promise((function(e,r){var d,m=t.data,v=t.headers,y=t.responseType;function g(){t.cancelToken&&t.cancelToken.unsubscribe(d),t.signal&&t.signal.removeEventListener("abort",d)}n.isFormData(m)&&delete v["Content-Type"];var b=new XMLHttpRequest;if(t.auth){var O=t.auth.username||"",E=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";v.Authorization="Basic "+btoa(O+":"+E)}var x=a(t.baseURL,t.url),w=h.parse(x),j=n.getProtocol(w.protocol);function R(){if(b){var n="getAllResponseHeaders"in b?u(b.getAllResponseHeaders()):null,s={data:y&&"text"!==y&&"json"!==y?b.response:b.responseText,status:b.status,statusText:b.statusText,headers:n,config:t,request:b};o((function(t){e(t),g()}),(function(t){r(t),g()}),s),b=null}}if(b.open(t.method.toUpperCase(),i(x,t.params,t.paramsSerializer),!0),b.timeout=t.timeout,"onloadend"in b?b.onloadend=R:b.onreadystatechange=function(){b&&4===b.readyState&&(0!==b.status||b.responseURL&&0===b.responseURL.indexOf("file:"))&&setTimeout(R)},b.onabort=function(){b&&(r(new l("Request aborted",l.ECONNABORTED,t,b)),b=null)},b.onerror=function(){r(new l("Network Error",l.ERR_NETWORK,t,b,b)),b=null},b.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",n=t.transitional||f;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(new l(e,n.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,t,b)),b=null},n.isStandardBrowserEnv()){var A=(t.withCredentials||c(x))&&t.xsrfCookieName?s.read(t.xsrfCookieName):void 0;A&&(v[t.xsrfHeaderName]=A)}"setRequestHeader"in b&&n.forEach(v,(function(t,e){void 0===m&&"content-type"===e.toLowerCase()?delete v[e]:b.setRequestHeader(e,t)})),n.isUndefined(t.withCredentials)||(b.withCredentials=!!t.withCredentials),y&&"json"!==y&&(b.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&b.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&b.upload&&b.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(d=function(t){b&&(r(!t||t&&t.type?new p:t),b.abort(),b=null)},t.cancelToken&&t.cancelToken.subscribe(d),t.signal&&(t.signal.aborted?d():t.signal.addEventListener("abort",d))),m||(m=null),null!==w.path?n.supportedProtocols.includes(j)?b.send(m):r(new l("Unsupported protocol "+j,l.ERR_BAD_REQUEST,t)):r(new l("Malformed URL "+x,l.ERR_BAD_REQUEST,t))}))}},function(t,e,r){"use strict";var n=r(21),o=r(22);t.exports=function(t,e){return t&&!n(e)?o(t,e):e}},function(t,e,r){"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t,e){e=e||{};var r={};function o(t,e){return n.isPlainObject(t)&&n.isPlainObject(e)?n.merge(t,e):n.isPlainObject(e)?n.merge({},e):n.isArray(e)?e.slice():e}function s(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:o(void 0,t[r]):o(t[r],e[r])}function i(t){if(!n.isUndefined(e[t]))return o(void 0,e[t])}function a(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:o(void 0,t[r]):o(void 0,e[r])}function u(r){return r in e?o(t[r],e[r]):r in t?o(void 0,t[r]):void 0}var c={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return n.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=c[t]||s,o=e(t);n.isUndefined(o)&&e!==u||(r[t]=o)})),r}},function(t,e){t.exports={version:"0.26.1"}},function(t,e,r){t.exports=r(13)},function(t,e,r){"use strict";var n=r(0),o=r(4),s=r(14),i=r(10);var a=function t(e){var r=new s(e),a=o(s.prototype.request,r);return n.extend(a,s.prototype,r),n.extend(a,r),a.create=function(r){return t(i(e,r))},a}(r(3));a.Axios=s,a.CanceledError=r(2),a.CancelToken=r(34),a.isCancel=r(9),a.VERSION=r(11).version,a.AxiosError=r(1),a.Cancel=a.CanceledError,a.all=function(t){return Promise.all(t)},a.spread=r(35),a.isAxiosError=r(36),t.exports=a,t.exports.default=a},function(t,e,r){"use strict";var n=r(0),o=r(5),s=r(15),i=r(16),a=r(10),u=r(8),c=r(33),h=c.validators;function f(t){this.defaults=t,this.interceptors={request:new s,response:new s}}f.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:h.transitional(h.boolean),forcedJSONParsing:h.transitional(h.boolean),clarifyTimeoutError:h.transitional(h.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(o=o&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var s,u=[];if(this.interceptors.response.forEach((function(t){u.push(t.fulfilled,t.rejected)})),!o){var f=[i,void 0];for(Array.prototype.unshift.apply(f,n),f=f.concat(u),s=Promise.resolve(e);f.length;)s=s.then(f.shift(),f.shift());return s}for(var l=e;n.length;){var p=n.shift(),d=n.shift();try{l=p(l)}catch(t){d(t);break}}try{s=i(l)}catch(t){return Promise.reject(t)}for(;u.length;)s=s.then(u.shift(),u.shift());return s},f.prototype.getUri=function(t){t=a(this.defaults,t);var e=u(t.baseURL,t.url);return o(e,t.params,t.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(t){f.prototype[t]=function(e,r){return this.request(a(r||{},{method:t,url:e,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(t){f.prototype[t]=function(e,r,n){return this.request(a(n||{},{method:t,url:e,data:r}))}})),t.exports=f},function(t,e,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},o.prototype.forEach=function(t){n.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=o},function(t,e,r){"use strict";var n=r(0),o=r(17),s=r(9),i=r(3),a=r(2);function u(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a}t.exports=function(t){return u(t),t.headers=t.headers||{},t.data=o.call(t,t.data,t.headers,t.transformRequest),t.headers=n.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||i.adapter)(t).then((function(e){return u(t),e.data=o.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return s(e)||(u(t),e&&e.response&&(e.response.data=o.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},function(t,e,r){"use strict";var n=r(0),o=r(3);t.exports=function(t,e,r){var s=this||o;return n.forEach(r,(function(r){t=r.call(s,t,e)})),t}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t,e){n.forEach(t,(function(r,n){n!==e&&n.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[n])}))}},function(t,e,r){"use strict";var n=r(1);t.exports=function(t,e,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?e(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}},function(t,e,r){"use strict";var n=r(0);t.exports=n.isStandardBrowserEnv()?{write:function(t,e,r,o,s,i){var a=[];a.push(t+"="+encodeURIComponent(e)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(s)&&a.push("domain="+s),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,r){"use strict";t.exports=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}},function(t,e,r){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,r){"use strict";var n=r(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,r,s,i={};return t?(n.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=n.trim(t.substr(0,s)).toLowerCase(),r=n.trim(t.substr(s+1)),e){if(i[e]&&o.indexOf(e)>=0)return;i[e]="set-cookie"===e?(i[e]?i[e]:[]).concat([r]):i[e]?i[e]+", "+r:r}})),i):i}},function(t,e,r){"use strict";var n=r(0);t.exports=n.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(t){var n=t;return e&&(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 t=o(window.location.href),function(e){var r=n.isString(e)?o(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}},function(t,e,r){"use strict";var n=r(26),o=r(29);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=b,e.resolve=function(t,e){return b(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?b(t,!1,!0).resolveObject(e):e},e.format=function(t){o.isString(t)&&(t=b(t));return t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var i=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(c),f=["%","/","?",";","#"].concat(h),l=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(30);function b(t,e,r){if(t&&o.isObject(t)&&t instanceof s)return t;var n=new s;return n.parse(t,e,r),n}s.prototype.parse=function(t,e,r){if(!o.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s<t.indexOf("#")?"?":"#",c=t.split(a);c[0]=c[0].replace(/\\/g,"/");var b=t=c.join(a);if(b=b.trim(),!r&&1===t.split("#").length){var O=u.exec(b);if(O)return this.path=b,this.href=b,this.pathname=O[1],O[2]?(this.search=O[2],this.query=e?g.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var E=i.exec(b);if(E){var x=(E=E[0]).toLowerCase();this.protocol=x,b=b.substr(E.length)}if(r||E||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var w="//"===b.substr(0,2);!w||E&&v[E]||(b=b.substr(2),this.slashes=!0)}if(!v[E]&&(w||E&&!y[E])){for(var j,R,A=-1,C=0;C<l.length;C++){-1!==(S=b.indexOf(l[C]))&&(-1===A||S<A)&&(A=S)}-1!==(R=-1===A?b.lastIndexOf("@"):b.lastIndexOf("@",A))&&(j=b.slice(0,R),b=b.slice(R+1),this.auth=decodeURIComponent(j)),A=-1;for(C=0;C<f.length;C++){var S;-1!==(S=b.indexOf(f[C]))&&(-1===A||S<A)&&(A=S)}-1===A&&(A=b.length),this.host=b.slice(0,A),b=b.slice(A),this.parseHost(),this.hostname=this.hostname||"";var _="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!_)for(var N=this.hostname.split(/\./),P=(C=0,N.length);C<P;C++){var T=N[C];if(T&&!T.match(p)){for(var U="",q=0,B=T.length;q<B;q++)T.charCodeAt(q)>127?U+="x":U+=T[q];if(!U.match(p)){var D=N.slice(0,C),I=N.slice(C+1),k=T.match(d);k&&(D.push(k[1]),I.unshift(k[2])),I.length&&(b="/"+I.join(".")+b),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=n.toASCII(this.hostname));var L=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+L,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[x])for(C=0,P=h.length;C<P;C++){var M=h[C];if(-1!==b.indexOf(M)){var z=encodeURIComponent(M);z===M&&(z=escape(M)),b=b.split(M).join(z)}}var H=b.indexOf("#");-1!==H&&(this.hash=b.substr(H),b=b.slice(0,H));var J=b.indexOf("?");if(-1!==J?(this.search=b.substr(J),this.query=b.substr(J+1),e&&(this.query=g.parse(this.query)),b=b.slice(0,J)):e&&(this.search="",this.query={}),b&&(this.pathname=b),y[x]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){L=this.pathname||"";var V=this.search||"";this.path=L+V}return this.href=this.format(),this},s.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",s=!1,i="";this.host?s=t+this.host:this.hostname&&(s=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(i=g.stringify(this.query));var a=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||y[e])&&!1!==s?(s="//"+(s||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):s||(s=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),e+s+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+n},s.prototype.resolve=function(t){return this.resolveObject(b(t,!1,!0)).format()},s.prototype.resolveObject=function(t){if(o.isString(t)){var e=new s;e.parse(t,!1,!0),t=e}for(var r=new s,n=Object.keys(this),i=0;i<n.length;i++){var a=n[i];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var u=Object.keys(t),c=0;c<u.length;c++){var h=u[c];"protocol"!==h&&(r[h]=t[h])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!y[t.protocol]){for(var f=Object.keys(t),l=0;l<f.length;l++){var p=f[l];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||v[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var b=r.pathname&&"/"===r.pathname.charAt(0),O=t.host||t.pathname&&"/"===t.pathname.charAt(0),E=O||b||r.host&&t.pathname,x=E,w=r.pathname&&r.pathname.split("/")||[],j=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(j&&(r.hostname="",r.port=null,r.host&&(""===w[0]?w[0]=r.host:w.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),E=E&&(""===d[0]||""===w[0])),O)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,w=d;else if(d.length)w||(w=[]),w.pop(),w=w.concat(d),r.search=t.search,r.query=t.query;else if(!o.isNullOrUndefined(t.search)){if(j)r.hostname=r.host=w.shift(),(_=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=_.shift(),r.host=r.hostname=_.shift());return r.search=t.search,r.query=t.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var R=w.slice(-1)[0],A=(r.host||t.host||w.length>1)&&("."===R||".."===R)||""===R,C=0,S=w.length;S>=0;S--)"."===(R=w[S])?w.splice(S,1):".."===R?(w.splice(S,1),C++):C&&(w.splice(S,1),C--);if(!E&&!x)for(;C--;C)w.unshift("..");!E||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),A&&"/"!==w.join("/").substr(-1)&&w.push("");var _,N=""===w[0]||w[0]&&"/"===w[0].charAt(0);j&&(r.hostname=r.host=N?"":w.length?w.shift():"",(_=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=_.shift(),r.host=r.hostname=_.shift()));return(E=E||r.host&&w.length)&&!N&&w.unshift(""),w.length?r.pathname=w.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){(function(t,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(s){e&&e.nodeType,t&&t.nodeType;var i="object"==typeof n&&n;i.global!==i&&i.window!==i&&i.self;var a,u=2147483647,c=/^xn--/,h=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,d=String.fromCharCode;function m(t){throw new RangeError(l[t])}function v(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function y(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+v((t=t.replace(f,".")).split("."),e).join(".")}function g(t){for(var e,r,n=[],o=0,s=t.length;o<s;)(e=t.charCodeAt(o++))>=55296&&e<=56319&&o<s?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function b(t){return v(t,(function(t){var e="";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=d(t)})).join("")}function O(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function E(t,e,r){var n=0;for(t=r?p(t/700):t>>1,t+=p(t/e);t>455;n+=36)t=p(t/35);return p(n+36*t/(t+38))}function x(t){var e,r,n,o,s,i,a,c,h,f,l,d=[],v=t.length,y=0,g=128,O=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&m("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;o<v;){for(s=y,i=1,a=36;o>=v&&m("invalid-input"),((c=(l=t.charCodeAt(o++))-48<10?l-22:l-65<26?l-65:l-97<26?l-97:36)>=36||c>p((u-y)/i))&&m("overflow"),y+=c*i,!(c<(h=a<=O?1:a>=O+26?26:a-O));a+=36)i>p(u/(f=36-h))&&m("overflow"),i*=f;O=E(y-s,e=d.length+1,0==s),p(y/e)>u-g&&m("overflow"),g+=p(y/e),y%=e,d.splice(y++,0,g)}return b(d)}function w(t){var e,r,n,o,s,i,a,c,h,f,l,v,y,b,x,w=[];for(v=(t=g(t)).length,e=128,r=0,s=72,i=0;i<v;++i)(l=t[i])<128&&w.push(d(l));for(n=o=w.length,o&&w.push("-");n<v;){for(a=u,i=0;i<v;++i)(l=t[i])>=e&&l<a&&(a=l);for(a-e>p((u-r)/(y=n+1))&&m("overflow"),r+=(a-e)*y,e=a,i=0;i<v;++i)if((l=t[i])<e&&++r>u&&m("overflow"),l==e){for(c=r,h=36;!(c<(f=h<=s?1:h>=s+26?26:h-s));h+=36)x=c-f,b=36-f,w.push(d(O(f+x%b,0))),c=p(x/b);w.push(d(O(c,0))),s=E(r,y,n==o),r=0,++n}++r,++e}return w.join("")}a={version:"1.4.1",ucs2:{decode:g,encode:b},decode:x,encode:w,toASCII:function(t){return y(t,(function(t){return h.test(t)?"xn--"+w(t):t}))},toUnicode:function(t){return y(t,(function(t){return c.test(t)?x(t.slice(4).toLowerCase()):t}))}},void 0===(o=function(){return a}.call(e,r,e,t))||(t.exports=o)}()}).call(this,r(27)(t),r(28))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){"use strict";e.decode=e.parse=r(31),e.encode=e.stringify=r(32)},function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,s){e=e||"&",r=r||"=";var i={};if("string"!=typeof t||0===t.length)return i;var a=/\+/g;t=t.split(e);var u=1e3;s&&"number"==typeof s.maxKeys&&(u=s.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var h=0;h<c;++h){var f,l,p,d,m=t[h].replace(a,"%20"),v=m.indexOf(r);v>=0?(f=m.substr(0,v),l=m.substr(v+1)):(f=m,l=""),p=decodeURIComponent(f),d=decodeURIComponent(l),n(i,p)?o(i[p])?i[p].push(d):i[p]=[i[p],d]:i[p]=d}return i};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?s(i(t),(function(i){var a=encodeURIComponent(n(i))+r;return o(t[i])?s(t[i],(function(t){return a+encodeURIComponent(n(t))})).join(e):a+encodeURIComponent(n(t[i]))})).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var i=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},function(t,e,r){"use strict";var n=r(11).version,o=r(1),s={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){s[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var i={};s.transitional=function(t,e,r){function s(t,e){return"[Axios v"+n+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,a){if(!1===t)throw new o(s(n," has been removed"+(e?" in "+e:"")),o.ERR_DEPRECATED);return e&&!i[n]&&(i[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,a)}},t.exports={assertOptions:function(t,e,r){if("object"!=typeof t)throw new o("options must be an object",o.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],a=e[i];if(a){var u=t[i],c=void 0===u||a(u,i,t);if(!0!==c)throw new o("option "+i+" must be "+c,o.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new o("Unknown option "+i,o.ERR_BAD_OPTION)}},validators:s}},function(t,e,r){"use strict";var n=r(2);function o(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;this.promise.then((function(t){if(r._listeners){var e,n=r._listeners.length;for(e=0;e<n;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,n=new Promise((function(t){r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t){r.reason||(r.reason=new n(t),e(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},o.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},o.source=function(){var t;return{token:new o((function(e){t=e})),cancel:t}},t.exports=o},function(t,e,r){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t){return n.isObject(t)&&!0===t.isAxiosError}}])})); | ||
//# sourceMappingURL=axios.min.map |
// TypeScript Version: 3.0 | ||
export type AxiosRequestHeaders = Record<string, string | number | boolean>; | ||
@@ -78,3 +77,3 @@ | ||
url?: string; | ||
method?: Method; | ||
method?: Method | string; | ||
baseURL?: string; | ||
@@ -102,2 +101,3 @@ transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; | ||
maxRedirects?: number; | ||
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void; | ||
socketPath?: string | null; | ||
@@ -112,2 +112,5 @@ httpAgent?: any; | ||
insecureHTTPParser?: boolean; | ||
env?: { | ||
FormData?: new (...args: any[]) => object; | ||
}; | ||
} | ||
@@ -142,3 +145,11 @@ | ||
export interface AxiosError<T = any, D = any> extends Error { | ||
export class AxiosError<T = unknown, D = any> extends Error { | ||
constructor( | ||
message?: string, | ||
code?: string, | ||
config?: AxiosRequestConfig<D>, | ||
request?: any, | ||
response?: AxiosResponse<T, D> | ||
); | ||
config: AxiosRequestConfig<D>; | ||
@@ -149,5 +160,19 @@ code?: string; | ||
isAxiosError: boolean; | ||
status?: string; | ||
toJSON: () => object; | ||
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS"; | ||
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; | ||
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION"; | ||
static readonly ERR_NETWORK = "ERR_NETWORK"; | ||
static readonly ERR_DEPRECATED = "ERR_DEPRECATED"; | ||
static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE"; | ||
static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST"; | ||
static readonly ERR_CANCELED = "ERR_CANCELED"; | ||
static readonly ECONNABORTED = "ECONNABORTED"; | ||
static readonly ETIMEDOUT = "ETIMEDOUT"; | ||
} | ||
export class CanceledError<T> extends AxiosError<T> { | ||
} | ||
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> { | ||
@@ -184,4 +209,9 @@ } | ||
export interface AxiosInterceptorOptions { | ||
synchronous?: boolean; | ||
runWhen?: (config: AxiosRequestConfig) => boolean; | ||
} | ||
export interface AxiosInterceptorManager<V> { | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number; | ||
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; | ||
eject(id: number): void; | ||
@@ -206,2 +236,5 @@ } | ||
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
postForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
putForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
patchForm<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>; | ||
} | ||
@@ -208,0 +241,0 @@ |
@@ -14,6 +14,5 @@ 'use strict'; | ||
var VERSION = require('./../env/data').version; | ||
var createError = require('../core/createError'); | ||
var enhanceError = require('../core/enhanceError'); | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var Cancel = require('../cancel/Cancel'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
@@ -91,3 +90,6 @@ var isHttps = /https:?/; | ||
if (data && !utils.isStream(data)) { | ||
// support for https://www.npmjs.com/package/form-data api | ||
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) { | ||
Object.assign(headers, data.getHeaders()); | ||
} else if (data && !utils.isStream(data)) { | ||
if (Buffer.isBuffer(data)) { | ||
@@ -100,4 +102,5 @@ // Nothing to do... | ||
} else { | ||
return reject(createError( | ||
return reject(new AxiosError( | ||
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
@@ -108,3 +111,7 @@ )); | ||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) { | ||
return reject(createError('Request body larger than maxBodyLength limit', config)); | ||
return reject(new AxiosError( | ||
'Request body larger than maxBodyLength limit', | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
@@ -129,4 +136,12 @@ | ||
var parsed = url.parse(fullPath); | ||
var protocol = parsed.protocol || 'http:'; | ||
var protocol = utils.getProtocol(parsed.protocol); | ||
if (!utils.supportedProtocols.includes(protocol)) { | ||
return reject(new AxiosError( | ||
'Unsupported protocol ' + protocol, | ||
AxiosError.ERR_BAD_REQUEST, | ||
config | ||
)); | ||
} | ||
if (!auth && parsed.auth) { | ||
@@ -235,2 +250,5 @@ var urlAuth = parsed.auth.split(':'); | ||
} | ||
if (config.beforeRedirect) { | ||
options.beforeRedirect = config.beforeRedirect; | ||
} | ||
transport = isHttpsProxy ? httpsFollow : httpFollow; | ||
@@ -297,4 +315,4 @@ } | ||
stream.destroy(); | ||
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
config, null, lastRequest)); | ||
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, config, lastRequest)); | ||
} | ||
@@ -308,3 +326,8 @@ }); | ||
stream.destroy(); | ||
reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest)); | ||
reject(new AxiosError( | ||
'maxContentLength size of ' + config.maxContentLength + ' exceeded', | ||
AxiosError.ERR_BAD_RESPONSE, | ||
config, | ||
lastRequest | ||
)); | ||
}); | ||
@@ -314,3 +337,3 @@ | ||
if (req.aborted) return; | ||
reject(enhanceError(err, config, null, lastRequest)); | ||
reject(AxiosError.from(err, null, config, lastRequest)); | ||
}); | ||
@@ -329,3 +352,3 @@ | ||
} catch (err) { | ||
reject(enhanceError(err, config, err.code, response.request, response)); | ||
reject(AxiosError.from(err, null, config, response.request, response)); | ||
} | ||
@@ -339,4 +362,5 @@ settle(resolve, reject, response); | ||
req.on('error', function handleRequestError(err) { | ||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return; | ||
reject(enhanceError(err, config, null, req)); | ||
// @todo remove | ||
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return; | ||
reject(AxiosError.from(err, null, config, req)); | ||
}); | ||
@@ -356,6 +380,6 @@ | ||
if (isNaN(timeout)) { | ||
reject(createError( | ||
reject(new AxiosError( | ||
'error trying to parse `config.timeout` to int', | ||
AxiosError.ERR_BAD_OPTION_VALUE, | ||
config, | ||
'ERR_PARSE_TIMEOUT', | ||
req | ||
@@ -374,13 +398,7 @@ )); | ||
req.abort(); | ||
var timeoutErrorMessage = ''; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} else { | ||
timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; | ||
} | ||
var transitional = config.transitional || transitionalDefaults; | ||
reject(createError( | ||
timeoutErrorMessage, | ||
reject(new AxiosError( | ||
'timeout of ' + timeout + 'ms exceeded', | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
req | ||
@@ -398,3 +416,3 @@ )); | ||
req.abort(); | ||
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); | ||
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); | ||
}; | ||
@@ -412,3 +430,3 @@ | ||
data.on('error', function handleStreamError(err) { | ||
reject(enhanceError(err, config, null, req)); | ||
reject(AxiosError.from(err, config, null, req)); | ||
}).pipe(req); | ||
@@ -415,0 +433,0 @@ } else { |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); | ||
var createError = require('../core/createError'); | ||
var url = require('url'); | ||
var transitionalDefaults = require('../defaults/transitional'); | ||
var Cancel = require('../cancel/Cancel'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
@@ -31,6 +32,2 @@ module.exports = function xhrAdapter(config) { | ||
if (utils.isFormData(requestData)) { | ||
delete requestHeaders['Content-Type']; // Let the browser set it | ||
} | ||
var request = new XMLHttpRequest(); | ||
@@ -46,2 +43,5 @@ | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
var parsed = url.parse(fullPath); | ||
var protocol = utils.getProtocol(parsed.protocol); | ||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
@@ -110,3 +110,3 @@ | ||
reject(createError('Request aborted', config, 'ECONNABORTED', request)); | ||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request)); | ||
@@ -121,3 +121,3 @@ // Clean up request | ||
// onerror should only fire if it's a network error | ||
reject(createError('Network Error', config, null, request)); | ||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request)); | ||
@@ -135,6 +135,6 @@ // Clean up request | ||
} | ||
reject(createError( | ||
reject(new AxiosError( | ||
timeoutErrorMessage, | ||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, | ||
config, | ||
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', | ||
request)); | ||
@@ -200,3 +200,3 @@ | ||
} | ||
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); | ||
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); | ||
request.abort(); | ||
@@ -216,2 +216,12 @@ request = null; | ||
if (parsed.path === null) { | ||
reject(new AxiosError('Malformed URL ' + fullPath, AxiosError.ERR_BAD_REQUEST, config)); | ||
return; | ||
} | ||
if (!utils.supportedProtocols.includes(protocol)) { | ||
reject(new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_BAD_REQUEST, config)); | ||
return; | ||
} | ||
// Send the request | ||
@@ -218,0 +228,0 @@ request.send(requestData); |
@@ -40,7 +40,14 @@ 'use strict'; | ||
// Expose Cancel & CancelToken | ||
axios.Cancel = require('./cancel/Cancel'); | ||
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'); | ||
// Expose AxiosError class | ||
axios.AxiosError = require('../lib/core/AxiosError'); | ||
// alias for CanceledError for backward compatibility | ||
axios.Cancel = axios.CanceledError; | ||
// Expose all/spread | ||
@@ -47,0 +54,0 @@ axios.all = function all(promises) { |
'use strict'; | ||
var Cancel = require('./Cancel'); | ||
var CanceledError = require('./CanceledError'); | ||
@@ -59,3 +59,3 @@ /** | ||
token.reason = new Cancel(message); | ||
token.reason = new CanceledError(message); | ||
resolvePromise(token.reason); | ||
@@ -66,3 +66,3 @@ }); | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
@@ -69,0 +69,0 @@ CancelToken.prototype.throwIfRequested = function throwIfRequested() { |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var mergeConfig = require('./mergeConfig'); | ||
var buildFullPath = require('./buildFullPath'); | ||
var validator = require('../helpers/validator'); | ||
@@ -123,3 +124,4 @@ | ||
config = mergeConfig(this.defaults, config); | ||
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
return buildURL(fullPath, config.params, config.paramsSerializer); | ||
}; | ||
@@ -141,11 +143,21 @@ | ||
/*eslint func-names:0*/ | ||
Axios.prototype[method] = function(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url, | ||
data: data | ||
})); | ||
}; | ||
function generateHTTPMethod(isForm) { | ||
return function httpMethod(url, data, config) { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
headers: isForm ? { | ||
'Content-Type': 'multipart/form-data' | ||
} : {}, | ||
url: url, | ||
data: data | ||
})); | ||
}; | ||
} | ||
Axios.prototype[method] = generateHTTPMethod(); | ||
Axios.prototype[method + 'Form'] = generateHTTPMethod(true); | ||
}); | ||
module.exports = Axios; |
@@ -7,6 +7,6 @@ 'use strict'; | ||
var defaults = require('../defaults'); | ||
var Cancel = require('../cancel/Cancel'); | ||
var CanceledError = require('../cancel/CanceledError'); | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
* Throws a `CanceledError` if cancellation has been requested. | ||
*/ | ||
@@ -19,3 +19,3 @@ function throwIfCancellationRequested(config) { | ||
if (config.signal && config.signal.aborted) { | ||
throw new Cancel('canceled'); | ||
throw new CanceledError(); | ||
} | ||
@@ -22,0 +22,0 @@ } |
@@ -83,2 +83,3 @@ 'use strict'; | ||
'maxBodyLength': defaultToConfig2, | ||
'beforeRedirect': defaultToConfig2, | ||
'transport': defaultToConfig2, | ||
@@ -85,0 +86,0 @@ 'httpAgent': defaultToConfig2, |
'use strict'; | ||
var createError = require('./createError'); | ||
var AxiosError = require('./AxiosError'); | ||
@@ -17,6 +17,6 @@ /** | ||
} else { | ||
reject(createError( | ||
reject(new AxiosError( | ||
'Request failed with status code ' + response.status, | ||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], | ||
response.config, | ||
null, | ||
response.request, | ||
@@ -23,0 +23,0 @@ response |
@@ -5,4 +5,5 @@ 'use strict'; | ||
var normalizeHeaderName = require('../helpers/normalizeHeaderName'); | ||
var enhanceError = require('../core/enhanceError'); | ||
var AxiosError = require('../core/AxiosError'); | ||
var transitionalDefaults = require('./transitional'); | ||
var toFormData = require('../helpers/toFormData'); | ||
@@ -72,6 +73,16 @@ var DEFAULT_CONTENT_TYPE = { | ||
} | ||
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { | ||
var isObjectPayload = utils.isObject(data); | ||
var contentType = headers && headers['Content-Type']; | ||
var isFileList; | ||
if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) { | ||
var _FormData = this.env && this.env.FormData; | ||
return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData()); | ||
} else if (isObjectPayload || contentType === 'application/json') { | ||
setContentTypeIfUnset(headers, 'application/json'); | ||
return stringifySafely(data); | ||
} | ||
return data; | ||
@@ -92,3 +103,3 @@ }], | ||
if (e.name === 'SyntaxError') { | ||
throw enhanceError(e, this, 'E_JSON_PARSE'); | ||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response); | ||
} | ||
@@ -115,2 +126,6 @@ throw e; | ||
env: { | ||
FormData: require('./env/FormData') | ||
}, | ||
validateStatus: function validateStatus(status) { | ||
@@ -117,0 +132,0 @@ return status >= 200 && status < 300; |
module.exports = { | ||
"version": "0.26.1" | ||
"version": "0.27.0" | ||
}; |
'use strict'; | ||
function combinedKey(parentKey, elKey) { | ||
return parentKey + '.' + elKey; | ||
} | ||
var utils = require('../utils'); | ||
function buildFormData(formData, data, parentKey) { | ||
if (Array.isArray(data)) { | ||
data.forEach(function buildArray(el, i) { | ||
buildFormData(formData, el, combinedKey(parentKey, i)); | ||
}); | ||
} else if ( | ||
typeof data === 'object' && | ||
!(data instanceof File || data === null) | ||
) { | ||
Object.keys(data).forEach(function buildObject(key) { | ||
buildFormData( | ||
formData, | ||
data[key], | ||
parentKey ? combinedKey(parentKey, key) : key | ||
); | ||
}); | ||
} else { | ||
if (data === undefined) { | ||
return; | ||
/** | ||
* Convert a data object to FormData | ||
* @param {Object} obj | ||
* @param {?Object} [formData] | ||
* @returns {Object} | ||
**/ | ||
function toFormData(obj, formData) { | ||
// eslint-disable-next-line no-param-reassign | ||
formData = formData || new FormData(); | ||
var stack = []; | ||
function convertValue(value) { | ||
if (value === null) return ''; | ||
if (utils.isDate(value)) { | ||
return value.toISOString(); | ||
} | ||
var value = | ||
typeof data === 'boolean' || typeof data === 'number' | ||
? data.toString() | ||
: data; | ||
formData.append(parentKey, value); | ||
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) { | ||
return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value); | ||
} | ||
return value; | ||
} | ||
} | ||
/** | ||
* convert a data object to FormData | ||
* | ||
* type FormDataPrimitive = string | Blob | number | boolean | ||
* interface FormDataNest { | ||
* [x: string]: FormVal | ||
* } | ||
* | ||
* type FormVal = FormDataNest | FormDataPrimitive | ||
* | ||
* @param {FormVal} data | ||
*/ | ||
function build(data, parentKey) { | ||
if (utils.isPlainObject(data) || utils.isArray(data)) { | ||
if (stack.indexOf(data) !== -1) { | ||
throw Error('Circular reference detected in ' + parentKey); | ||
} | ||
module.exports = function getFormData(data) { | ||
var formData = new FormData(); | ||
stack.push(data); | ||
buildFormData(formData, data); | ||
utils.forEach(data, function each(value, key) { | ||
if (utils.isUndefined(value)) return; | ||
var fullKey = parentKey ? parentKey + '.' + key : key; | ||
var arr; | ||
if (value && !parentKey && typeof value === 'object') { | ||
if (utils.endsWith(key, '{}')) { | ||
// eslint-disable-next-line no-param-reassign | ||
value = JSON.stringify(value); | ||
} else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) { | ||
// eslint-disable-next-line func-names | ||
arr.forEach(function(el) { | ||
!utils.isUndefined(el) && formData.append(fullKey, convertValue(el)); | ||
}); | ||
return; | ||
} | ||
} | ||
build(value, fullKey); | ||
}); | ||
stack.pop(); | ||
} else { | ||
formData.append(parentKey, convertValue(data)); | ||
} | ||
} | ||
build(obj); | ||
return formData; | ||
}; | ||
} | ||
module.exports = toFormData; |
'use strict'; | ||
var VERSION = require('../env/data').version; | ||
var AxiosError = require('../core/AxiosError'); | ||
@@ -31,3 +32,6 @@ var validators = {}; | ||
if (validator === false) { | ||
throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); | ||
throw new AxiosError( | ||
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), | ||
AxiosError.ERR_DEPRECATED | ||
); | ||
} | ||
@@ -59,3 +63,3 @@ | ||
if (typeof options !== 'object') { | ||
throw new TypeError('options must be an object'); | ||
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
@@ -71,3 +75,3 @@ var keys = Object.keys(options); | ||
if (result !== true) { | ||
throw new TypeError('option ' + opt + ' must be ' + result); | ||
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE); | ||
} | ||
@@ -77,3 +81,3 @@ continue; | ||
if (allowUnknown !== true) { | ||
throw Error('Unknown option ' + opt); | ||
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION); | ||
} | ||
@@ -80,0 +84,0 @@ } |
193
lib/utils.js
@@ -9,3 +9,35 @@ 'use strict'; | ||
// eslint-disable-next-line func-names | ||
var kindOf = (function(cache) { | ||
// eslint-disable-next-line func-names | ||
return function(thing) { | ||
var str = toString.call(thing); | ||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase()); | ||
}; | ||
})(Object.create(null)); | ||
function kindOfTest(type) { | ||
type = type.toLowerCase(); | ||
return function isKindOf(thing) { | ||
return kindOf(thing) === type; | ||
}; | ||
} | ||
/** | ||
* Array with axios supported protocols. | ||
*/ | ||
var supportedProtocols = [ 'http:', 'https:', 'file:' ]; | ||
/** | ||
* Returns URL protocol passed as param if is not undefined or null, | ||
* otherwise just returns 'http:' | ||
* | ||
* @param {String} protocol The String value of URL protocol | ||
* @returns {String} Protocol if the value is not undefined or null | ||
*/ | ||
function getProtocol(protocol) { | ||
return protocol || 'http:'; | ||
} | ||
/** | ||
* Determine if a value is an Array | ||
@@ -44,18 +76,8 @@ * | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBuffer(val) { | ||
return toString.call(val) === '[object ArrayBuffer]'; | ||
} | ||
var isArrayBuffer = kindOfTest('ArrayBuffer'); | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
function isFormData(val) { | ||
return toString.call(val) === '[object FormData]'; | ||
} | ||
@@ -115,3 +137,3 @@ /** | ||
function isPlainObject(val) { | ||
if (toString.call(val) !== '[object Object]') { | ||
if (kindOf(val) !== 'object') { | ||
return false; | ||
@@ -127,8 +149,7 @@ } | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
function isDate(val) { | ||
return toString.call(val) === '[object Date]'; | ||
} | ||
var isDate = kindOfTest('Date'); | ||
@@ -138,8 +159,7 @@ /** | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFile(val) { | ||
return toString.call(val) === '[object File]'; | ||
} | ||
var isFile = kindOfTest('File'); | ||
@@ -149,10 +169,18 @@ /** | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
function isBlob(val) { | ||
return toString.call(val) === '[object Blob]'; | ||
} | ||
var isBlob = kindOfTest('Blob'); | ||
/** | ||
* Determine if a value is a FileList | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
var isFileList = kindOfTest('FileList'); | ||
/** | ||
* Determine if a value is a Function | ||
@@ -178,10 +206,23 @@ * | ||
/** | ||
* Determine if a value is a FormData | ||
* | ||
* @param {Object} thing The value to test | ||
* @returns {boolean} True if value is an FormData, otherwise false | ||
*/ | ||
function isFormData(thing) { | ||
var pattern = '[object FormData]'; | ||
return thing && ( | ||
(typeof FormData === 'function' && thing instanceof FormData) || | ||
toString.call(thing) === pattern || | ||
(isFunction(thing.toString) && thing.toString() === pattern) | ||
); | ||
} | ||
/** | ||
* Determine if a value is a URLSearchParams object | ||
* | ||
* @function | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false | ||
*/ | ||
function isURLSearchParams(val) { | ||
return toString.call(val) === '[object URLSearchParams]'; | ||
} | ||
var isURLSearchParams = kindOfTest('URLSearchParams'); | ||
@@ -333,3 +374,93 @@ /** | ||
/** | ||
* Inherit the prototype methods from one constructor into another | ||
* @param {function} constructor | ||
* @param {function} superConstructor | ||
* @param {object} [props] | ||
* @param {object} [descriptors] | ||
*/ | ||
function inherits(constructor, superConstructor, props, descriptors) { | ||
constructor.prototype = Object.create(superConstructor.prototype, descriptors); | ||
constructor.prototype.constructor = constructor; | ||
props && Object.assign(constructor.prototype, props); | ||
} | ||
/** | ||
* Resolve object with deep prototype chain to a flat object | ||
* @param {Object} sourceObj source object | ||
* @param {Object} [destObj] | ||
* @param {Function} [filter] | ||
* @returns {Object} | ||
*/ | ||
function toFlatObject(sourceObj, destObj, filter) { | ||
var props; | ||
var i; | ||
var prop; | ||
var merged = {}; | ||
destObj = destObj || {}; | ||
do { | ||
props = Object.getOwnPropertyNames(sourceObj); | ||
i = props.length; | ||
while (i-- > 0) { | ||
prop = props[i]; | ||
if (!merged[prop]) { | ||
destObj[prop] = sourceObj[prop]; | ||
merged[prop] = true; | ||
} | ||
} | ||
sourceObj = Object.getPrototypeOf(sourceObj); | ||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype); | ||
return destObj; | ||
} | ||
/* | ||
* 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) { | ||
str = String(str); | ||
if (position === undefined || position > str.length) { | ||
position = str.length; | ||
} | ||
position -= searchString.length; | ||
var lastIndex = str.indexOf(searchString, position); | ||
return lastIndex !== -1 && lastIndex === position; | ||
} | ||
/** | ||
* Returns new array from array like object | ||
* @param {*} [thing] | ||
* @returns {Array} | ||
*/ | ||
function toArray(thing) { | ||
if (!thing) return null; | ||
var i = thing.length; | ||
if (isUndefined(i)) return null; | ||
var arr = new Array(i); | ||
while (i-- > 0) { | ||
arr[i] = thing[i]; | ||
} | ||
return arr; | ||
} | ||
// eslint-disable-next-line func-names | ||
var isTypedArray = (function(TypedArray) { | ||
// eslint-disable-next-line func-names | ||
return function(thing) { | ||
return TypedArray && thing instanceof TypedArray; | ||
}; | ||
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array)); | ||
module.exports = { | ||
supportedProtocols: supportedProtocols, | ||
getProtocol: getProtocol, | ||
isArray: isArray, | ||
@@ -356,3 +487,11 @@ isArrayBuffer: isArrayBuffer, | ||
trim: trim, | ||
stripBOM: stripBOM | ||
stripBOM: stripBOM, | ||
inherits: inherits, | ||
toFlatObject: toFlatObject, | ||
kindOf: kindOf, | ||
kindOfTest: kindOfTest, | ||
endsWith: endsWith, | ||
toArray: toArray, | ||
isTypedArray: isTypedArray, | ||
isFileList: isFileList | ||
}; |
{ | ||
"name": "axios", | ||
"version": "0.26.1", | ||
"version": "0.27.0", | ||
"description": "Promise based HTTP client for the browser and node.js", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"start": "node ./sandbox/server.js", | ||
"build": "NODE_ENV=production grunt build", | ||
"build": "cross-env NODE_ENV=production grunt build", | ||
"preversion": "grunt version && npm test", | ||
@@ -37,20 +37,22 @@ "version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json", | ||
"devDependencies": { | ||
"abortcontroller-polyfill": "^1.5.0", | ||
"coveralls": "^3.0.0", | ||
"dtslint": "^4.1.6", | ||
"es6-promise": "^4.2.4", | ||
"grunt": "^1.3.0", | ||
"abortcontroller-polyfill": "^1.7.3", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"dtslint": "^4.2.1", | ||
"es6-promise": "^4.2.8", | ||
"formidable": "^2.0.1", | ||
"grunt": "^1.4.1", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-eslint": "^23.0.0", | ||
"grunt-karma": "^4.0.0", | ||
"grunt-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-webpack": "^4.0.2", | ||
"istanbul-instrumenter-loader": "^1.0.0", | ||
"grunt-webpack": "^5.0.0", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^6.3.2", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma": "^6.3.17", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-jasmine": "^1.1.1", | ||
@@ -63,8 +65,8 @@ "karma-jasmine-ajax": "^0.1.13", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^3.5.2", | ||
"minimist": "^1.2.0", | ||
"load-grunt-tasks": "^5.1.0", | ||
"minimist": "^1.2.6", | ||
"mocha": "^8.2.1", | ||
"sinon": "^4.5.0", | ||
"terser-webpack-plugin": "^4.2.3", | ||
"typescript": "^4.0.5", | ||
"typescript": "^4.6.3", | ||
"url-search-params": "^0.10.0", | ||
@@ -75,3 +77,4 @@ "webpack": "^4.44.2", | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js" | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js", | ||
"./lib/defaults/env/FormData.js": "./lib/helpers/null.js" | ||
}, | ||
@@ -82,3 +85,4 @@ "jsdelivr": "dist/axios.min.js", | ||
"dependencies": { | ||
"follow-redirects": "^1.14.8" | ||
"follow-redirects": "^1.14.9", | ||
"form-data": "^4.0.0" | ||
}, | ||
@@ -85,0 +89,0 @@ "bundlesize": [ |
146
README.md
@@ -26,3 +26,3 @@ # axios | ||
- [Request method aliases](#request-method-aliases) | ||
- [Concurrency (Deprecated)](#concurrency-deprecated) | ||
- [Concurrency 👎](#concurrency-deprecated) | ||
- [Creating an instance](#creating-an-instance) | ||
@@ -40,2 +40,4 @@ - [Instance methods](#instance-methods) | ||
- [Cancellation](#cancellation) | ||
- [AbortController](#abortcontroller) | ||
- [CancelToken 👎](#canceltoken-deprecated) | ||
- [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) | ||
@@ -46,2 +48,4 @@ - [Browser](#browser) | ||
- [Form data](#form-data) | ||
- [Automatic serialization](#-automatic-serialization) | ||
- [Manual FormData passing](#manual-formdata-passing) | ||
- [Semver](#semver) | ||
@@ -119,3 +123,3 @@ - [Promises](#promises) | ||
```js | ||
const axios = require('axios'); | ||
const axios = require('axios').default; | ||
@@ -238,3 +242,3 @@ // Make a request for a user with a given ID | ||
For convenience aliases have been provided for all supported request methods. | ||
For convenience, aliases have been provided for all common request methods. | ||
@@ -422,4 +426,15 @@ ##### axios.request(config) | ||
// If set to 0, no redirects will be followed. | ||
maxRedirects: 5, // default | ||
maxRedirects: 21, // default | ||
// `beforeRedirect` defines a function that will be called before redirect. | ||
// Use this to adjust the request options upon redirecting, | ||
// to inspect the latest response headers, | ||
// or to cancel the request by throwing an error | ||
// If maxRedirects is set to 0, `beforeRedirect` is not used. | ||
beforeRedirect: (options, { headers }) => { | ||
if (options.hostname === "example.com") { | ||
options.auth = "user:password"; | ||
} | ||
}; | ||
// `socketPath` defines a UNIX Socket to be used in node.js. | ||
@@ -492,2 +507,7 @@ // e.g. '/var/run/docker.sock' to send requests to the docker daemon. | ||
clarifyTimeoutError: false, | ||
}, | ||
env: { | ||
// The FormData class to be used to automatically serialize the payload into a FormData object | ||
FormData: window?.FormData || global?.FormData | ||
} | ||
@@ -717,6 +737,26 @@ } | ||
You can cancel a request using a *cancel token*. | ||
### AbortController | ||
Starting from `v0.22.0` Axios supports AbortController to cancel requests in fetch API way: | ||
```js | ||
const controller = new AbortController(); | ||
axios.get('/foo/bar', { | ||
signal: controller.signal | ||
}).then(function(response) { | ||
//... | ||
}); | ||
// cancel the request | ||
controller.abort() | ||
``` | ||
### CancelToken `👎deprecated` | ||
You can also cancel a request using a *CancelToken*. | ||
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
> This API is deprecated since v0.22.0 and shouldn't be used in new projects | ||
You can create a cancel token using the `CancelToken.source` factory as shown below: | ||
@@ -765,18 +805,7 @@ | ||
Axios supports AbortController to abort requests in [`fetch API`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#aborting_a_fetch) way: | ||
```js | ||
const controller = new AbortController(); | ||
axios.get('/foo/bar', { | ||
signal: controller.signal | ||
}).then(function(response) { | ||
//... | ||
}); | ||
// cancel the request | ||
controller.abort() | ||
``` | ||
> 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 real request. | ||
> During the transition period, you can use both cancellation APIs, even for the same request: | ||
## Using application/x-www-form-urlencoded format | ||
@@ -841,7 +870,71 @@ | ||
###### NOTE | ||
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). | ||
> 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. | ||
#### Form data | ||
##### 🆕 Automatic serialization | ||
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`. | ||
The following request will submit the data in a FormData format (Browser & Node.js): | ||
```js | ||
import axios from 'axios'; | ||
axios.post('https://httpbin.org/post', {x: 1}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default. | ||
You can overload the FormData class by setting the `env.FormData` config variable, | ||
but you probably won't need it in most cases: | ||
```js | ||
const axios= require('axios'); | ||
var FormData = require('form-data'); | ||
axios.post('https://httpbin.org/post', {x: 1, buf: new Buffer(10)}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
Axios FormData serializer supports some special endings to perform the following operations: | ||
- `{}` - serialize the value with JSON.stringify | ||
- `[]` - unwrap the array like object as separate fields with the same key | ||
```js | ||
const axios= require('axios'); | ||
axios.post('https://httpbin.org/post', { | ||
'myObj{}': {x: 1, s: "foo"}, | ||
'files[]': document.querySelector('#fileInput').files | ||
}, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}).then(({data})=> console.log(data)); | ||
``` | ||
Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` | ||
which are just the corresponding http methods with a header preset: `Content-Type`: `multipart/form-data`. | ||
FileList object can be passed directly: | ||
```js | ||
await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) | ||
``` | ||
All files will be sent with the same field names: `files[]`; | ||
##### Manual FormData passing | ||
In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
@@ -857,16 +950,5 @@ | ||
axios.post('https://example.com', form, { headers: form.getHeaders() }) | ||
axios.post('https://example.com', form) | ||
``` | ||
Alternatively, use an interceptor: | ||
```js | ||
axios.interceptors.request.use(config => { | ||
if (config.data instanceof FormData) { | ||
Object.assign(config.headers, config.data.getHeaders()); | ||
} | ||
return config; | ||
}); | ||
``` | ||
## Semver | ||
@@ -873,0 +955,0 @@ |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
608129
51
5935
992
2
36
1
+ Addedform-data@^4.0.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
Updatedfollow-redirects@^1.14.9