axios.js 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595
  1. /* axios v0.27.2 | (c) 2022 by Matt Zabriskie */
  2. (function webpackUniversalModuleDefinition(root, factory) {
  3. if(typeof exports === 'object' && typeof module === 'object')
  4. module.exports = factory();
  5. else if(typeof define === 'function' && define.amd)
  6. define([], factory);
  7. else if(typeof exports === 'object')
  8. exports["axios"] = factory();
  9. else
  10. root["axios"] = factory();
  11. })(this, function() {
  12. return /******/ (function(modules) { // webpackBootstrap
  13. /******/ // The module cache
  14. /******/ var installedModules = {};
  15. /******/
  16. /******/ // The require function
  17. /******/ function __webpack_require__(moduleId) {
  18. /******/
  19. /******/ // Check if module is in cache
  20. /******/ if(installedModules[moduleId]) {
  21. /******/ return installedModules[moduleId].exports;
  22. /******/ }
  23. /******/ // Create a new module (and put it into the cache)
  24. /******/ var module = installedModules[moduleId] = {
  25. /******/ i: moduleId,
  26. /******/ l: false,
  27. /******/ exports: {}
  28. /******/ };
  29. /******/
  30. /******/ // Execute the module function
  31. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  32. /******/
  33. /******/ // Flag the module as loaded
  34. /******/ module.l = true;
  35. /******/
  36. /******/ // Return the exports of the module
  37. /******/ return module.exports;
  38. /******/ }
  39. /******/
  40. /******/
  41. /******/ // expose the modules object (__webpack_modules__)
  42. /******/ __webpack_require__.m = modules;
  43. /******/
  44. /******/ // expose the module cache
  45. /******/ __webpack_require__.c = installedModules;
  46. /******/
  47. /******/ // define getter function for harmony exports
  48. /******/ __webpack_require__.d = function(exports, name, getter) {
  49. /******/ if(!__webpack_require__.o(exports, name)) {
  50. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  51. /******/ }
  52. /******/ };
  53. /******/
  54. /******/ // define __esModule on exports
  55. /******/ __webpack_require__.r = function(exports) {
  56. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  57. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  58. /******/ }
  59. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  60. /******/ };
  61. /******/
  62. /******/ // create a fake namespace object
  63. /******/ // mode & 1: value is a module id, require it
  64. /******/ // mode & 2: merge all properties of value into the ns
  65. /******/ // mode & 4: return value when already ns object
  66. /******/ // mode & 8|1: behave like require
  67. /******/ __webpack_require__.t = function(value, mode) {
  68. /******/ if(mode & 1) value = __webpack_require__(value);
  69. /******/ if(mode & 8) return value;
  70. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  71. /******/ var ns = Object.create(null);
  72. /******/ __webpack_require__.r(ns);
  73. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  74. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  75. /******/ return ns;
  76. /******/ };
  77. /******/
  78. /******/ // getDefaultExport function for compatibility with non-harmony modules
  79. /******/ __webpack_require__.n = function(module) {
  80. /******/ var getter = module && module.__esModule ?
  81. /******/ function getDefault() { return module['default']; } :
  82. /******/ function getModuleExports() { return module; };
  83. /******/ __webpack_require__.d(getter, 'a', getter);
  84. /******/ return getter;
  85. /******/ };
  86. /******/
  87. /******/ // Object.prototype.hasOwnProperty.call
  88. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  89. /******/
  90. /******/ // __webpack_public_path__
  91. /******/ __webpack_require__.p = "";
  92. /******/
  93. /******/
  94. /******/ // Load entry module and return exports
  95. /******/ return __webpack_require__(__webpack_require__.s = "./index.js");
  96. /******/ })
  97. /************************************************************************/
  98. /******/ ({
  99. /***/ "./index.js":
  100. /*!******************!*\
  101. !*** ./index.js ***!
  102. \******************/
  103. /*! no static exports found */
  104. /***/ (function(module, exports, __webpack_require__) {
  105. module.exports = __webpack_require__(/*! ./lib/axios */ "./lib/axios.js");
  106. /***/ }),
  107. /***/ "./lib/adapters/xhr.js":
  108. /*!*****************************!*\
  109. !*** ./lib/adapters/xhr.js ***!
  110. \*****************************/
  111. /*! no static exports found */
  112. /***/ (function(module, exports, __webpack_require__) {
  113. "use strict";
  114. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  115. var settle = __webpack_require__(/*! ./../core/settle */ "./lib/core/settle.js");
  116. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./lib/helpers/cookies.js");
  117. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/buildURL.js");
  118. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
  119. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
  120. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
  121. var transitionalDefaults = __webpack_require__(/*! ../defaults/transitional */ "./lib/defaults/transitional.js");
  122. var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
  123. var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
  124. var parseProtocol = __webpack_require__(/*! ../helpers/parseProtocol */ "./lib/helpers/parseProtocol.js");
  125. module.exports = function xhrAdapter(config) {
  126. return new Promise(function dispatchXhrRequest(resolve, reject) {
  127. var requestData = config.data;
  128. var requestHeaders = config.headers;
  129. var responseType = config.responseType;
  130. var onCanceled;
  131. function done() {
  132. if (config.cancelToken) {
  133. config.cancelToken.unsubscribe(onCanceled);
  134. }
  135. if (config.signal) {
  136. config.signal.removeEventListener('abort', onCanceled);
  137. }
  138. }
  139. if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
  140. delete requestHeaders['Content-Type']; // Let the browser set it
  141. }
  142. var request = new XMLHttpRequest();
  143. // HTTP basic authentication
  144. if (config.auth) {
  145. var username = config.auth.username || '';
  146. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  147. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  148. }
  149. var fullPath = buildFullPath(config.baseURL, config.url);
  150. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  151. // Set the request timeout in MS
  152. request.timeout = config.timeout;
  153. function onloadend() {
  154. if (!request) {
  155. return;
  156. }
  157. // Prepare the response
  158. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  159. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  160. request.responseText : request.response;
  161. var response = {
  162. data: responseData,
  163. status: request.status,
  164. statusText: request.statusText,
  165. headers: responseHeaders,
  166. config: config,
  167. request: request
  168. };
  169. settle(function _resolve(value) {
  170. resolve(value);
  171. done();
  172. }, function _reject(err) {
  173. reject(err);
  174. done();
  175. }, response);
  176. // Clean up request
  177. request = null;
  178. }
  179. if ('onloadend' in request) {
  180. // Use onloadend if available
  181. request.onloadend = onloadend;
  182. } else {
  183. // Listen for ready state to emulate onloadend
  184. request.onreadystatechange = function handleLoad() {
  185. if (!request || request.readyState !== 4) {
  186. return;
  187. }
  188. // The request errored out and we didn't get a response, this will be
  189. // handled by onerror instead
  190. // With one exception: request that using file: protocol, most browsers
  191. // will return status as 0 even though it's a successful request
  192. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  193. return;
  194. }
  195. // readystate handler is calling before onerror or ontimeout handlers,
  196. // so we should call onloadend on the next 'tick'
  197. setTimeout(onloadend);
  198. };
  199. }
  200. // Handle browser request cancellation (as opposed to a manual cancellation)
  201. request.onabort = function handleAbort() {
  202. if (!request) {
  203. return;
  204. }
  205. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  206. // Clean up request
  207. request = null;
  208. };
  209. // Handle low level network errors
  210. request.onerror = function handleError() {
  211. // Real errors are hidden from us by the browser
  212. // onerror should only fire if it's a network error
  213. reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
  214. // Clean up request
  215. request = null;
  216. };
  217. // Handle timeout
  218. request.ontimeout = function handleTimeout() {
  219. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  220. var transitional = config.transitional || transitionalDefaults;
  221. if (config.timeoutErrorMessage) {
  222. timeoutErrorMessage = config.timeoutErrorMessage;
  223. }
  224. reject(new AxiosError(
  225. timeoutErrorMessage,
  226. transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  227. config,
  228. request));
  229. // Clean up request
  230. request = null;
  231. };
  232. // Add xsrf header
  233. // This is only done if running in a standard browser environment.
  234. // Specifically not if we're in a web worker, or react-native.
  235. if (utils.isStandardBrowserEnv()) {
  236. // Add xsrf header
  237. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  238. cookies.read(config.xsrfCookieName) :
  239. undefined;
  240. if (xsrfValue) {
  241. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  242. }
  243. }
  244. // Add headers to the request
  245. if ('setRequestHeader' in request) {
  246. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  247. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  248. // Remove Content-Type if data is undefined
  249. delete requestHeaders[key];
  250. } else {
  251. // Otherwise add header to the request
  252. request.setRequestHeader(key, val);
  253. }
  254. });
  255. }
  256. // Add withCredentials to request if needed
  257. if (!utils.isUndefined(config.withCredentials)) {
  258. request.withCredentials = !!config.withCredentials;
  259. }
  260. // Add responseType to request if needed
  261. if (responseType && responseType !== 'json') {
  262. request.responseType = config.responseType;
  263. }
  264. // Handle progress if needed
  265. if (typeof config.onDownloadProgress === 'function') {
  266. request.addEventListener('progress', config.onDownloadProgress);
  267. }
  268. // Not all browsers support upload events
  269. if (typeof config.onUploadProgress === 'function' && request.upload) {
  270. request.upload.addEventListener('progress', config.onUploadProgress);
  271. }
  272. if (config.cancelToken || config.signal) {
  273. // Handle cancellation
  274. // eslint-disable-next-line func-names
  275. onCanceled = function(cancel) {
  276. if (!request) {
  277. return;
  278. }
  279. reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
  280. request.abort();
  281. request = null;
  282. };
  283. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  284. if (config.signal) {
  285. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  286. }
  287. }
  288. if (!requestData) {
  289. requestData = null;
  290. }
  291. var protocol = parseProtocol(fullPath);
  292. if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
  293. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  294. return;
  295. }
  296. // Send the request
  297. request.send(requestData);
  298. });
  299. };
  300. /***/ }),
  301. /***/ "./lib/axios.js":
  302. /*!**********************!*\
  303. !*** ./lib/axios.js ***!
  304. \**********************/
  305. /*! no static exports found */
  306. /***/ (function(module, exports, __webpack_require__) {
  307. "use strict";
  308. var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
  309. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  310. var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
  311. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
  312. var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults/index.js");
  313. /**
  314. * Create an instance of Axios
  315. *
  316. * @param {Object} defaultConfig The default config for the instance
  317. * @return {Axios} A new instance of Axios
  318. */
  319. function createInstance(defaultConfig) {
  320. var context = new Axios(defaultConfig);
  321. var instance = bind(Axios.prototype.request, context);
  322. // Copy axios.prototype to instance
  323. utils.extend(instance, Axios.prototype, context);
  324. // Copy context to instance
  325. utils.extend(instance, context);
  326. // Factory for creating new instances
  327. instance.create = function create(instanceConfig) {
  328. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  329. };
  330. return instance;
  331. }
  332. // Create the default instance to be exported
  333. var axios = createInstance(defaults);
  334. // Expose Axios class to allow class inheritance
  335. axios.Axios = Axios;
  336. // Expose Cancel & CancelToken
  337. axios.CanceledError = __webpack_require__(/*! ./cancel/CanceledError */ "./lib/cancel/CanceledError.js");
  338. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
  339. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
  340. axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
  341. axios.toFormData = __webpack_require__(/*! ./helpers/toFormData */ "./lib/helpers/toFormData.js");
  342. // Expose AxiosError class
  343. axios.AxiosError = __webpack_require__(/*! ../lib/core/AxiosError */ "./lib/core/AxiosError.js");
  344. // alias for CanceledError for backward compatibility
  345. axios.Cancel = axios.CanceledError;
  346. // Expose all/spread
  347. axios.all = function all(promises) {
  348. return Promise.all(promises);
  349. };
  350. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./lib/helpers/spread.js");
  351. // Expose isAxiosError
  352. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./lib/helpers/isAxiosError.js");
  353. module.exports = axios;
  354. // Allow use of default import syntax in TypeScript
  355. module.exports.default = axios;
  356. /***/ }),
  357. /***/ "./lib/cancel/CancelToken.js":
  358. /*!***********************************!*\
  359. !*** ./lib/cancel/CancelToken.js ***!
  360. \***********************************/
  361. /*! no static exports found */
  362. /***/ (function(module, exports, __webpack_require__) {
  363. "use strict";
  364. var CanceledError = __webpack_require__(/*! ./CanceledError */ "./lib/cancel/CanceledError.js");
  365. /**
  366. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  367. *
  368. * @class
  369. * @param {Function} executor The executor function.
  370. */
  371. function CancelToken(executor) {
  372. if (typeof executor !== 'function') {
  373. throw new TypeError('executor must be a function.');
  374. }
  375. var resolvePromise;
  376. this.promise = new Promise(function promiseExecutor(resolve) {
  377. resolvePromise = resolve;
  378. });
  379. var token = this;
  380. // eslint-disable-next-line func-names
  381. this.promise.then(function(cancel) {
  382. if (!token._listeners) return;
  383. var i;
  384. var l = token._listeners.length;
  385. for (i = 0; i < l; i++) {
  386. token._listeners[i](cancel);
  387. }
  388. token._listeners = null;
  389. });
  390. // eslint-disable-next-line func-names
  391. this.promise.then = function(onfulfilled) {
  392. var _resolve;
  393. // eslint-disable-next-line func-names
  394. var promise = new Promise(function(resolve) {
  395. token.subscribe(resolve);
  396. _resolve = resolve;
  397. }).then(onfulfilled);
  398. promise.cancel = function reject() {
  399. token.unsubscribe(_resolve);
  400. };
  401. return promise;
  402. };
  403. executor(function cancel(message) {
  404. if (token.reason) {
  405. // Cancellation has already been requested
  406. return;
  407. }
  408. token.reason = new CanceledError(message);
  409. resolvePromise(token.reason);
  410. });
  411. }
  412. /**
  413. * Throws a `CanceledError` if cancellation has been requested.
  414. */
  415. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  416. if (this.reason) {
  417. throw this.reason;
  418. }
  419. };
  420. /**
  421. * Subscribe to the cancel signal
  422. */
  423. CancelToken.prototype.subscribe = function subscribe(listener) {
  424. if (this.reason) {
  425. listener(this.reason);
  426. return;
  427. }
  428. if (this._listeners) {
  429. this._listeners.push(listener);
  430. } else {
  431. this._listeners = [listener];
  432. }
  433. };
  434. /**
  435. * Unsubscribe from the cancel signal
  436. */
  437. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  438. if (!this._listeners) {
  439. return;
  440. }
  441. var index = this._listeners.indexOf(listener);
  442. if (index !== -1) {
  443. this._listeners.splice(index, 1);
  444. }
  445. };
  446. /**
  447. * Returns an object that contains a new `CancelToken` and a function that, when called,
  448. * cancels the `CancelToken`.
  449. */
  450. CancelToken.source = function source() {
  451. var cancel;
  452. var token = new CancelToken(function executor(c) {
  453. cancel = c;
  454. });
  455. return {
  456. token: token,
  457. cancel: cancel
  458. };
  459. };
  460. module.exports = CancelToken;
  461. /***/ }),
  462. /***/ "./lib/cancel/CanceledError.js":
  463. /*!*************************************!*\
  464. !*** ./lib/cancel/CanceledError.js ***!
  465. \*************************************/
  466. /*! no static exports found */
  467. /***/ (function(module, exports, __webpack_require__) {
  468. "use strict";
  469. var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
  470. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  471. /**
  472. * A `CanceledError` is an object that is thrown when an operation is canceled.
  473. *
  474. * @class
  475. * @param {string=} message The message.
  476. */
  477. function CanceledError(message) {
  478. // eslint-disable-next-line no-eq-null,eqeqeq
  479. AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
  480. this.name = 'CanceledError';
  481. }
  482. utils.inherits(CanceledError, AxiosError, {
  483. __CANCEL__: true
  484. });
  485. module.exports = CanceledError;
  486. /***/ }),
  487. /***/ "./lib/cancel/isCancel.js":
  488. /*!********************************!*\
  489. !*** ./lib/cancel/isCancel.js ***!
  490. \********************************/
  491. /*! no static exports found */
  492. /***/ (function(module, exports, __webpack_require__) {
  493. "use strict";
  494. module.exports = function isCancel(value) {
  495. return !!(value && value.__CANCEL__);
  496. };
  497. /***/ }),
  498. /***/ "./lib/core/Axios.js":
  499. /*!***************************!*\
  500. !*** ./lib/core/Axios.js ***!
  501. \***************************/
  502. /*! no static exports found */
  503. /***/ (function(module, exports, __webpack_require__) {
  504. "use strict";
  505. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  506. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/buildURL.js");
  507. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
  508. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
  509. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
  510. var buildFullPath = __webpack_require__(/*! ./buildFullPath */ "./lib/core/buildFullPath.js");
  511. var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
  512. var validators = validator.validators;
  513. /**
  514. * Create a new instance of Axios
  515. *
  516. * @param {Object} instanceConfig The default config for the instance
  517. */
  518. function Axios(instanceConfig) {
  519. this.defaults = instanceConfig;
  520. this.interceptors = {
  521. request: new InterceptorManager(),
  522. response: new InterceptorManager()
  523. };
  524. }
  525. /**
  526. * Dispatch a request
  527. *
  528. * @param {Object} config The config specific for this request (merged with this.defaults)
  529. */
  530. Axios.prototype.request = function request(configOrUrl, config) {
  531. /*eslint no-param-reassign:0*/
  532. // Allow for axios('example/url'[, config]) a la fetch API
  533. if (typeof configOrUrl === 'string') {
  534. config = config || {};
  535. config.url = configOrUrl;
  536. } else {
  537. config = configOrUrl || {};
  538. }
  539. config = mergeConfig(this.defaults, config);
  540. // Set config.method
  541. if (config.method) {
  542. config.method = config.method.toLowerCase();
  543. } else if (this.defaults.method) {
  544. config.method = this.defaults.method.toLowerCase();
  545. } else {
  546. config.method = 'get';
  547. }
  548. var transitional = config.transitional;
  549. if (transitional !== undefined) {
  550. validator.assertOptions(transitional, {
  551. silentJSONParsing: validators.transitional(validators.boolean),
  552. forcedJSONParsing: validators.transitional(validators.boolean),
  553. clarifyTimeoutError: validators.transitional(validators.boolean)
  554. }, false);
  555. }
  556. // filter out skipped interceptors
  557. var requestInterceptorChain = [];
  558. var synchronousRequestInterceptors = true;
  559. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  560. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  561. return;
  562. }
  563. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  564. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  565. });
  566. var responseInterceptorChain = [];
  567. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  568. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  569. });
  570. var promise;
  571. if (!synchronousRequestInterceptors) {
  572. var chain = [dispatchRequest, undefined];
  573. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  574. chain = chain.concat(responseInterceptorChain);
  575. promise = Promise.resolve(config);
  576. while (chain.length) {
  577. promise = promise.then(chain.shift(), chain.shift());
  578. }
  579. return promise;
  580. }
  581. var newConfig = config;
  582. while (requestInterceptorChain.length) {
  583. var onFulfilled = requestInterceptorChain.shift();
  584. var onRejected = requestInterceptorChain.shift();
  585. try {
  586. newConfig = onFulfilled(newConfig);
  587. } catch (error) {
  588. onRejected(error);
  589. break;
  590. }
  591. }
  592. try {
  593. promise = dispatchRequest(newConfig);
  594. } catch (error) {
  595. return Promise.reject(error);
  596. }
  597. while (responseInterceptorChain.length) {
  598. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  599. }
  600. return promise;
  601. };
  602. Axios.prototype.getUri = function getUri(config) {
  603. config = mergeConfig(this.defaults, config);
  604. var fullPath = buildFullPath(config.baseURL, config.url);
  605. return buildURL(fullPath, config.params, config.paramsSerializer);
  606. };
  607. // Provide aliases for supported request methods
  608. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  609. /*eslint func-names:0*/
  610. Axios.prototype[method] = function(url, config) {
  611. return this.request(mergeConfig(config || {}, {
  612. method: method,
  613. url: url,
  614. data: (config || {}).data
  615. }));
  616. };
  617. });
  618. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  619. /*eslint func-names:0*/
  620. function generateHTTPMethod(isForm) {
  621. return function httpMethod(url, data, config) {
  622. return this.request(mergeConfig(config || {}, {
  623. method: method,
  624. headers: isForm ? {
  625. 'Content-Type': 'multipart/form-data'
  626. } : {},
  627. url: url,
  628. data: data
  629. }));
  630. };
  631. }
  632. Axios.prototype[method] = generateHTTPMethod();
  633. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  634. });
  635. module.exports = Axios;
  636. /***/ }),
  637. /***/ "./lib/core/AxiosError.js":
  638. /*!********************************!*\
  639. !*** ./lib/core/AxiosError.js ***!
  640. \********************************/
  641. /*! no static exports found */
  642. /***/ (function(module, exports, __webpack_require__) {
  643. "use strict";
  644. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  645. /**
  646. * Create an Error with the specified message, config, error code, request and response.
  647. *
  648. * @param {string} message The error message.
  649. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  650. * @param {Object} [config] The config.
  651. * @param {Object} [request] The request.
  652. * @param {Object} [response] The response.
  653. * @returns {Error} The created error.
  654. */
  655. function AxiosError(message, code, config, request, response) {
  656. Error.call(this);
  657. this.message = message;
  658. this.name = 'AxiosError';
  659. code && (this.code = code);
  660. config && (this.config = config);
  661. request && (this.request = request);
  662. response && (this.response = response);
  663. }
  664. utils.inherits(AxiosError, Error, {
  665. toJSON: function toJSON() {
  666. return {
  667. // Standard
  668. message: this.message,
  669. name: this.name,
  670. // Microsoft
  671. description: this.description,
  672. number: this.number,
  673. // Mozilla
  674. fileName: this.fileName,
  675. lineNumber: this.lineNumber,
  676. columnNumber: this.columnNumber,
  677. stack: this.stack,
  678. // Axios
  679. config: this.config,
  680. code: this.code,
  681. status: this.response && this.response.status ? this.response.status : null
  682. };
  683. }
  684. });
  685. var prototype = AxiosError.prototype;
  686. var descriptors = {};
  687. [
  688. 'ERR_BAD_OPTION_VALUE',
  689. 'ERR_BAD_OPTION',
  690. 'ECONNABORTED',
  691. 'ETIMEDOUT',
  692. 'ERR_NETWORK',
  693. 'ERR_FR_TOO_MANY_REDIRECTS',
  694. 'ERR_DEPRECATED',
  695. 'ERR_BAD_RESPONSE',
  696. 'ERR_BAD_REQUEST',
  697. 'ERR_CANCELED'
  698. // eslint-disable-next-line func-names
  699. ].forEach(function(code) {
  700. descriptors[code] = {value: code};
  701. });
  702. Object.defineProperties(AxiosError, descriptors);
  703. Object.defineProperty(prototype, 'isAxiosError', {value: true});
  704. // eslint-disable-next-line func-names
  705. AxiosError.from = function(error, code, config, request, response, customProps) {
  706. var axiosError = Object.create(prototype);
  707. utils.toFlatObject(error, axiosError, function filter(obj) {
  708. return obj !== Error.prototype;
  709. });
  710. AxiosError.call(axiosError, error.message, code, config, request, response);
  711. axiosError.name = error.name;
  712. customProps && Object.assign(axiosError, customProps);
  713. return axiosError;
  714. };
  715. module.exports = AxiosError;
  716. /***/ }),
  717. /***/ "./lib/core/InterceptorManager.js":
  718. /*!****************************************!*\
  719. !*** ./lib/core/InterceptorManager.js ***!
  720. \****************************************/
  721. /*! no static exports found */
  722. /***/ (function(module, exports, __webpack_require__) {
  723. "use strict";
  724. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  725. function InterceptorManager() {
  726. this.handlers = [];
  727. }
  728. /**
  729. * Add a new interceptor to the stack
  730. *
  731. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  732. * @param {Function} rejected The function to handle `reject` for a `Promise`
  733. *
  734. * @return {Number} An ID used to remove interceptor later
  735. */
  736. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  737. this.handlers.push({
  738. fulfilled: fulfilled,
  739. rejected: rejected,
  740. synchronous: options ? options.synchronous : false,
  741. runWhen: options ? options.runWhen : null
  742. });
  743. return this.handlers.length - 1;
  744. };
  745. /**
  746. * Remove an interceptor from the stack
  747. *
  748. * @param {Number} id The ID that was returned by `use`
  749. */
  750. InterceptorManager.prototype.eject = function eject(id) {
  751. if (this.handlers[id]) {
  752. this.handlers[id] = null;
  753. }
  754. };
  755. /**
  756. * Iterate over all the registered interceptors
  757. *
  758. * This method is particularly useful for skipping over any
  759. * interceptors that may have become `null` calling `eject`.
  760. *
  761. * @param {Function} fn The function to call for each interceptor
  762. */
  763. InterceptorManager.prototype.forEach = function forEach(fn) {
  764. utils.forEach(this.handlers, function forEachHandler(h) {
  765. if (h !== null) {
  766. fn(h);
  767. }
  768. });
  769. };
  770. module.exports = InterceptorManager;
  771. /***/ }),
  772. /***/ "./lib/core/buildFullPath.js":
  773. /*!***********************************!*\
  774. !*** ./lib/core/buildFullPath.js ***!
  775. \***********************************/
  776. /*! no static exports found */
  777. /***/ (function(module, exports, __webpack_require__) {
  778. "use strict";
  779. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./lib/helpers/isAbsoluteURL.js");
  780. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./lib/helpers/combineURLs.js");
  781. /**
  782. * Creates a new URL by combining the baseURL with the requestedURL,
  783. * only when the requestedURL is not already an absolute URL.
  784. * If the requestURL is absolute, this function returns the requestedURL untouched.
  785. *
  786. * @param {string} baseURL The base URL
  787. * @param {string} requestedURL Absolute or relative URL to combine
  788. * @returns {string} The combined full path
  789. */
  790. module.exports = function buildFullPath(baseURL, requestedURL) {
  791. if (baseURL && !isAbsoluteURL(requestedURL)) {
  792. return combineURLs(baseURL, requestedURL);
  793. }
  794. return requestedURL;
  795. };
  796. /***/ }),
  797. /***/ "./lib/core/dispatchRequest.js":
  798. /*!*************************************!*\
  799. !*** ./lib/core/dispatchRequest.js ***!
  800. \*************************************/
  801. /*! no static exports found */
  802. /***/ (function(module, exports, __webpack_require__) {
  803. "use strict";
  804. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  805. var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
  806. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
  807. var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
  808. var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
  809. /**
  810. * Throws a `CanceledError` if cancellation has been requested.
  811. */
  812. function throwIfCancellationRequested(config) {
  813. if (config.cancelToken) {
  814. config.cancelToken.throwIfRequested();
  815. }
  816. if (config.signal && config.signal.aborted) {
  817. throw new CanceledError();
  818. }
  819. }
  820. /**
  821. * Dispatch a request to the server using the configured adapter.
  822. *
  823. * @param {object} config The config that is to be used for the request
  824. * @returns {Promise} The Promise to be fulfilled
  825. */
  826. module.exports = function dispatchRequest(config) {
  827. throwIfCancellationRequested(config);
  828. // Ensure headers exist
  829. config.headers = config.headers || {};
  830. // Transform request data
  831. config.data = transformData.call(
  832. config,
  833. config.data,
  834. config.headers,
  835. config.transformRequest
  836. );
  837. // Flatten headers
  838. config.headers = utils.merge(
  839. config.headers.common || {},
  840. config.headers[config.method] || {},
  841. config.headers
  842. );
  843. utils.forEach(
  844. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  845. function cleanHeaderConfig(method) {
  846. delete config.headers[method];
  847. }
  848. );
  849. var adapter = config.adapter || defaults.adapter;
  850. return adapter(config).then(function onAdapterResolution(response) {
  851. throwIfCancellationRequested(config);
  852. // Transform response data
  853. response.data = transformData.call(
  854. config,
  855. response.data,
  856. response.headers,
  857. config.transformResponse
  858. );
  859. return response;
  860. }, function onAdapterRejection(reason) {
  861. if (!isCancel(reason)) {
  862. throwIfCancellationRequested(config);
  863. // Transform response data
  864. if (reason && reason.response) {
  865. reason.response.data = transformData.call(
  866. config,
  867. reason.response.data,
  868. reason.response.headers,
  869. config.transformResponse
  870. );
  871. }
  872. }
  873. return Promise.reject(reason);
  874. });
  875. };
  876. /***/ }),
  877. /***/ "./lib/core/mergeConfig.js":
  878. /*!*********************************!*\
  879. !*** ./lib/core/mergeConfig.js ***!
  880. \*********************************/
  881. /*! no static exports found */
  882. /***/ (function(module, exports, __webpack_require__) {
  883. "use strict";
  884. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  885. /**
  886. * Config-specific merge-function which creates a new config-object
  887. * by merging two configuration objects together.
  888. *
  889. * @param {Object} config1
  890. * @param {Object} config2
  891. * @returns {Object} New object resulting from merging config2 to config1
  892. */
  893. module.exports = function mergeConfig(config1, config2) {
  894. // eslint-disable-next-line no-param-reassign
  895. config2 = config2 || {};
  896. var config = {};
  897. function getMergedValue(target, source) {
  898. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  899. return utils.merge(target, source);
  900. } else if (utils.isPlainObject(source)) {
  901. return utils.merge({}, source);
  902. } else if (utils.isArray(source)) {
  903. return source.slice();
  904. }
  905. return source;
  906. }
  907. // eslint-disable-next-line consistent-return
  908. function mergeDeepProperties(prop) {
  909. if (!utils.isUndefined(config2[prop])) {
  910. return getMergedValue(config1[prop], config2[prop]);
  911. } else if (!utils.isUndefined(config1[prop])) {
  912. return getMergedValue(undefined, config1[prop]);
  913. }
  914. }
  915. // eslint-disable-next-line consistent-return
  916. function valueFromConfig2(prop) {
  917. if (!utils.isUndefined(config2[prop])) {
  918. return getMergedValue(undefined, config2[prop]);
  919. }
  920. }
  921. // eslint-disable-next-line consistent-return
  922. function defaultToConfig2(prop) {
  923. if (!utils.isUndefined(config2[prop])) {
  924. return getMergedValue(undefined, config2[prop]);
  925. } else if (!utils.isUndefined(config1[prop])) {
  926. return getMergedValue(undefined, config1[prop]);
  927. }
  928. }
  929. // eslint-disable-next-line consistent-return
  930. function mergeDirectKeys(prop) {
  931. if (prop in config2) {
  932. return getMergedValue(config1[prop], config2[prop]);
  933. } else if (prop in config1) {
  934. return getMergedValue(undefined, config1[prop]);
  935. }
  936. }
  937. var mergeMap = {
  938. 'url': valueFromConfig2,
  939. 'method': valueFromConfig2,
  940. 'data': valueFromConfig2,
  941. 'baseURL': defaultToConfig2,
  942. 'transformRequest': defaultToConfig2,
  943. 'transformResponse': defaultToConfig2,
  944. 'paramsSerializer': defaultToConfig2,
  945. 'timeout': defaultToConfig2,
  946. 'timeoutMessage': defaultToConfig2,
  947. 'withCredentials': defaultToConfig2,
  948. 'adapter': defaultToConfig2,
  949. 'responseType': defaultToConfig2,
  950. 'xsrfCookieName': defaultToConfig2,
  951. 'xsrfHeaderName': defaultToConfig2,
  952. 'onUploadProgress': defaultToConfig2,
  953. 'onDownloadProgress': defaultToConfig2,
  954. 'decompress': defaultToConfig2,
  955. 'maxContentLength': defaultToConfig2,
  956. 'maxBodyLength': defaultToConfig2,
  957. 'beforeRedirect': defaultToConfig2,
  958. 'transport': defaultToConfig2,
  959. 'httpAgent': defaultToConfig2,
  960. 'httpsAgent': defaultToConfig2,
  961. 'cancelToken': defaultToConfig2,
  962. 'socketPath': defaultToConfig2,
  963. 'responseEncoding': defaultToConfig2,
  964. 'validateStatus': mergeDirectKeys
  965. };
  966. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  967. var merge = mergeMap[prop] || mergeDeepProperties;
  968. var configValue = merge(prop);
  969. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  970. });
  971. return config;
  972. };
  973. /***/ }),
  974. /***/ "./lib/core/settle.js":
  975. /*!****************************!*\
  976. !*** ./lib/core/settle.js ***!
  977. \****************************/
  978. /*! no static exports found */
  979. /***/ (function(module, exports, __webpack_require__) {
  980. "use strict";
  981. var AxiosError = __webpack_require__(/*! ./AxiosError */ "./lib/core/AxiosError.js");
  982. /**
  983. * Resolve or reject a Promise based on response status.
  984. *
  985. * @param {Function} resolve A function that resolves the promise.
  986. * @param {Function} reject A function that rejects the promise.
  987. * @param {object} response The response.
  988. */
  989. module.exports = function settle(resolve, reject, response) {
  990. var validateStatus = response.config.validateStatus;
  991. if (!response.status || !validateStatus || validateStatus(response.status)) {
  992. resolve(response);
  993. } else {
  994. reject(new AxiosError(
  995. 'Request failed with status code ' + response.status,
  996. [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  997. response.config,
  998. response.request,
  999. response
  1000. ));
  1001. }
  1002. };
  1003. /***/ }),
  1004. /***/ "./lib/core/transformData.js":
  1005. /*!***********************************!*\
  1006. !*** ./lib/core/transformData.js ***!
  1007. \***********************************/
  1008. /*! no static exports found */
  1009. /***/ (function(module, exports, __webpack_require__) {
  1010. "use strict";
  1011. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1012. var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
  1013. /**
  1014. * Transform the data for a request or a response
  1015. *
  1016. * @param {Object|String} data The data to be transformed
  1017. * @param {Array} headers The headers for the request or response
  1018. * @param {Array|Function} fns A single function or Array of functions
  1019. * @returns {*} The resulting transformed data
  1020. */
  1021. module.exports = function transformData(data, headers, fns) {
  1022. var context = this || defaults;
  1023. /*eslint no-param-reassign:0*/
  1024. utils.forEach(fns, function transform(fn) {
  1025. data = fn.call(context, data, headers);
  1026. });
  1027. return data;
  1028. };
  1029. /***/ }),
  1030. /***/ "./lib/defaults/index.js":
  1031. /*!*******************************!*\
  1032. !*** ./lib/defaults/index.js ***!
  1033. \*******************************/
  1034. /*! no static exports found */
  1035. /***/ (function(module, exports, __webpack_require__) {
  1036. "use strict";
  1037. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  1038. var normalizeHeaderName = __webpack_require__(/*! ../helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
  1039. var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
  1040. var transitionalDefaults = __webpack_require__(/*! ./transitional */ "./lib/defaults/transitional.js");
  1041. var toFormData = __webpack_require__(/*! ../helpers/toFormData */ "./lib/helpers/toFormData.js");
  1042. var DEFAULT_CONTENT_TYPE = {
  1043. 'Content-Type': 'application/x-www-form-urlencoded'
  1044. };
  1045. function setContentTypeIfUnset(headers, value) {
  1046. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  1047. headers['Content-Type'] = value;
  1048. }
  1049. }
  1050. function getDefaultAdapter() {
  1051. var adapter;
  1052. if (typeof XMLHttpRequest !== 'undefined') {
  1053. // For browsers use XHR adapter
  1054. adapter = __webpack_require__(/*! ../adapters/xhr */ "./lib/adapters/xhr.js");
  1055. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  1056. // For node use HTTP adapter
  1057. adapter = __webpack_require__(/*! ../adapters/http */ "./lib/adapters/xhr.js");
  1058. }
  1059. return adapter;
  1060. }
  1061. function stringifySafely(rawValue, parser, encoder) {
  1062. if (utils.isString(rawValue)) {
  1063. try {
  1064. (parser || JSON.parse)(rawValue);
  1065. return utils.trim(rawValue);
  1066. } catch (e) {
  1067. if (e.name !== 'SyntaxError') {
  1068. throw e;
  1069. }
  1070. }
  1071. }
  1072. return (encoder || JSON.stringify)(rawValue);
  1073. }
  1074. var defaults = {
  1075. transitional: transitionalDefaults,
  1076. adapter: getDefaultAdapter(),
  1077. transformRequest: [function transformRequest(data, headers) {
  1078. normalizeHeaderName(headers, 'Accept');
  1079. normalizeHeaderName(headers, 'Content-Type');
  1080. if (utils.isFormData(data) ||
  1081. utils.isArrayBuffer(data) ||
  1082. utils.isBuffer(data) ||
  1083. utils.isStream(data) ||
  1084. utils.isFile(data) ||
  1085. utils.isBlob(data)
  1086. ) {
  1087. return data;
  1088. }
  1089. if (utils.isArrayBufferView(data)) {
  1090. return data.buffer;
  1091. }
  1092. if (utils.isURLSearchParams(data)) {
  1093. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1094. return data.toString();
  1095. }
  1096. var isObjectPayload = utils.isObject(data);
  1097. var contentType = headers && headers['Content-Type'];
  1098. var isFileList;
  1099. if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
  1100. var _FormData = this.env && this.env.FormData;
  1101. return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
  1102. } else if (isObjectPayload || contentType === 'application/json') {
  1103. setContentTypeIfUnset(headers, 'application/json');
  1104. return stringifySafely(data);
  1105. }
  1106. return data;
  1107. }],
  1108. transformResponse: [function transformResponse(data) {
  1109. var transitional = this.transitional || defaults.transitional;
  1110. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  1111. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1112. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  1113. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  1114. try {
  1115. return JSON.parse(data);
  1116. } catch (e) {
  1117. if (strictJSONParsing) {
  1118. if (e.name === 'SyntaxError') {
  1119. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  1120. }
  1121. throw e;
  1122. }
  1123. }
  1124. }
  1125. return data;
  1126. }],
  1127. /**
  1128. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1129. * timeout is not created.
  1130. */
  1131. timeout: 0,
  1132. xsrfCookieName: 'XSRF-TOKEN',
  1133. xsrfHeaderName: 'X-XSRF-TOKEN',
  1134. maxContentLength: -1,
  1135. maxBodyLength: -1,
  1136. env: {
  1137. FormData: __webpack_require__(/*! ./env/FormData */ "./lib/helpers/null.js")
  1138. },
  1139. validateStatus: function validateStatus(status) {
  1140. return status >= 200 && status < 300;
  1141. },
  1142. headers: {
  1143. common: {
  1144. 'Accept': 'application/json, text/plain, */*'
  1145. }
  1146. }
  1147. };
  1148. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1149. defaults.headers[method] = {};
  1150. });
  1151. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1152. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1153. });
  1154. module.exports = defaults;
  1155. /***/ }),
  1156. /***/ "./lib/defaults/transitional.js":
  1157. /*!**************************************!*\
  1158. !*** ./lib/defaults/transitional.js ***!
  1159. \**************************************/
  1160. /*! no static exports found */
  1161. /***/ (function(module, exports, __webpack_require__) {
  1162. "use strict";
  1163. module.exports = {
  1164. silentJSONParsing: true,
  1165. forcedJSONParsing: true,
  1166. clarifyTimeoutError: false
  1167. };
  1168. /***/ }),
  1169. /***/ "./lib/env/data.js":
  1170. /*!*************************!*\
  1171. !*** ./lib/env/data.js ***!
  1172. \*************************/
  1173. /*! no static exports found */
  1174. /***/ (function(module, exports) {
  1175. module.exports = {
  1176. "version": "0.27.2"
  1177. };
  1178. /***/ }),
  1179. /***/ "./lib/helpers/bind.js":
  1180. /*!*****************************!*\
  1181. !*** ./lib/helpers/bind.js ***!
  1182. \*****************************/
  1183. /*! no static exports found */
  1184. /***/ (function(module, exports, __webpack_require__) {
  1185. "use strict";
  1186. module.exports = function bind(fn, thisArg) {
  1187. return function wrap() {
  1188. var args = new Array(arguments.length);
  1189. for (var i = 0; i < args.length; i++) {
  1190. args[i] = arguments[i];
  1191. }
  1192. return fn.apply(thisArg, args);
  1193. };
  1194. };
  1195. /***/ }),
  1196. /***/ "./lib/helpers/buildURL.js":
  1197. /*!*********************************!*\
  1198. !*** ./lib/helpers/buildURL.js ***!
  1199. \*********************************/
  1200. /*! no static exports found */
  1201. /***/ (function(module, exports, __webpack_require__) {
  1202. "use strict";
  1203. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1204. function encode(val) {
  1205. return encodeURIComponent(val).
  1206. replace(/%3A/gi, ':').
  1207. replace(/%24/g, '$').
  1208. replace(/%2C/gi, ',').
  1209. replace(/%20/g, '+').
  1210. replace(/%5B/gi, '[').
  1211. replace(/%5D/gi, ']');
  1212. }
  1213. /**
  1214. * Build a URL by appending params to the end
  1215. *
  1216. * @param {string} url The base of the url (e.g., http://www.google.com)
  1217. * @param {object} [params] The params to be appended
  1218. * @returns {string} The formatted url
  1219. */
  1220. module.exports = function buildURL(url, params, paramsSerializer) {
  1221. /*eslint no-param-reassign:0*/
  1222. if (!params) {
  1223. return url;
  1224. }
  1225. var serializedParams;
  1226. if (paramsSerializer) {
  1227. serializedParams = paramsSerializer(params);
  1228. } else if (utils.isURLSearchParams(params)) {
  1229. serializedParams = params.toString();
  1230. } else {
  1231. var parts = [];
  1232. utils.forEach(params, function serialize(val, key) {
  1233. if (val === null || typeof val === 'undefined') {
  1234. return;
  1235. }
  1236. if (utils.isArray(val)) {
  1237. key = key + '[]';
  1238. } else {
  1239. val = [val];
  1240. }
  1241. utils.forEach(val, function parseValue(v) {
  1242. if (utils.isDate(v)) {
  1243. v = v.toISOString();
  1244. } else if (utils.isObject(v)) {
  1245. v = JSON.stringify(v);
  1246. }
  1247. parts.push(encode(key) + '=' + encode(v));
  1248. });
  1249. });
  1250. serializedParams = parts.join('&');
  1251. }
  1252. if (serializedParams) {
  1253. var hashmarkIndex = url.indexOf('#');
  1254. if (hashmarkIndex !== -1) {
  1255. url = url.slice(0, hashmarkIndex);
  1256. }
  1257. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1258. }
  1259. return url;
  1260. };
  1261. /***/ }),
  1262. /***/ "./lib/helpers/combineURLs.js":
  1263. /*!************************************!*\
  1264. !*** ./lib/helpers/combineURLs.js ***!
  1265. \************************************/
  1266. /*! no static exports found */
  1267. /***/ (function(module, exports, __webpack_require__) {
  1268. "use strict";
  1269. /**
  1270. * Creates a new URL by combining the specified URLs
  1271. *
  1272. * @param {string} baseURL The base URL
  1273. * @param {string} relativeURL The relative URL
  1274. * @returns {string} The combined URL
  1275. */
  1276. module.exports = function combineURLs(baseURL, relativeURL) {
  1277. return relativeURL
  1278. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1279. : baseURL;
  1280. };
  1281. /***/ }),
  1282. /***/ "./lib/helpers/cookies.js":
  1283. /*!********************************!*\
  1284. !*** ./lib/helpers/cookies.js ***!
  1285. \********************************/
  1286. /*! no static exports found */
  1287. /***/ (function(module, exports, __webpack_require__) {
  1288. "use strict";
  1289. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1290. module.exports = (
  1291. utils.isStandardBrowserEnv() ?
  1292. // Standard browser envs support document.cookie
  1293. (function standardBrowserEnv() {
  1294. return {
  1295. write: function write(name, value, expires, path, domain, secure) {
  1296. var cookie = [];
  1297. cookie.push(name + '=' + encodeURIComponent(value));
  1298. if (utils.isNumber(expires)) {
  1299. cookie.push('expires=' + new Date(expires).toGMTString());
  1300. }
  1301. if (utils.isString(path)) {
  1302. cookie.push('path=' + path);
  1303. }
  1304. if (utils.isString(domain)) {
  1305. cookie.push('domain=' + domain);
  1306. }
  1307. if (secure === true) {
  1308. cookie.push('secure');
  1309. }
  1310. document.cookie = cookie.join('; ');
  1311. },
  1312. read: function read(name) {
  1313. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1314. return (match ? decodeURIComponent(match[3]) : null);
  1315. },
  1316. remove: function remove(name) {
  1317. this.write(name, '', Date.now() - 86400000);
  1318. }
  1319. };
  1320. })() :
  1321. // Non standard browser env (web workers, react-native) lack needed support.
  1322. (function nonStandardBrowserEnv() {
  1323. return {
  1324. write: function write() {},
  1325. read: function read() { return null; },
  1326. remove: function remove() {}
  1327. };
  1328. })()
  1329. );
  1330. /***/ }),
  1331. /***/ "./lib/helpers/isAbsoluteURL.js":
  1332. /*!**************************************!*\
  1333. !*** ./lib/helpers/isAbsoluteURL.js ***!
  1334. \**************************************/
  1335. /*! no static exports found */
  1336. /***/ (function(module, exports, __webpack_require__) {
  1337. "use strict";
  1338. /**
  1339. * Determines whether the specified URL is absolute
  1340. *
  1341. * @param {string} url The URL to test
  1342. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1343. */
  1344. module.exports = function isAbsoluteURL(url) {
  1345. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1346. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1347. // by any combination of letters, digits, plus, period, or hyphen.
  1348. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1349. };
  1350. /***/ }),
  1351. /***/ "./lib/helpers/isAxiosError.js":
  1352. /*!*************************************!*\
  1353. !*** ./lib/helpers/isAxiosError.js ***!
  1354. \*************************************/
  1355. /*! no static exports found */
  1356. /***/ (function(module, exports, __webpack_require__) {
  1357. "use strict";
  1358. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1359. /**
  1360. * Determines whether the payload is an error thrown by Axios
  1361. *
  1362. * @param {*} payload The value to test
  1363. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1364. */
  1365. module.exports = function isAxiosError(payload) {
  1366. return utils.isObject(payload) && (payload.isAxiosError === true);
  1367. };
  1368. /***/ }),
  1369. /***/ "./lib/helpers/isURLSameOrigin.js":
  1370. /*!****************************************!*\
  1371. !*** ./lib/helpers/isURLSameOrigin.js ***!
  1372. \****************************************/
  1373. /*! no static exports found */
  1374. /***/ (function(module, exports, __webpack_require__) {
  1375. "use strict";
  1376. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1377. module.exports = (
  1378. utils.isStandardBrowserEnv() ?
  1379. // Standard browser envs have full support of the APIs needed to test
  1380. // whether the request URL is of the same origin as current location.
  1381. (function standardBrowserEnv() {
  1382. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1383. var urlParsingNode = document.createElement('a');
  1384. var originURL;
  1385. /**
  1386. * Parse a URL to discover it's components
  1387. *
  1388. * @param {String} url The URL to be parsed
  1389. * @returns {Object}
  1390. */
  1391. function resolveURL(url) {
  1392. var href = url;
  1393. if (msie) {
  1394. // IE needs attribute set twice to normalize properties
  1395. urlParsingNode.setAttribute('href', href);
  1396. href = urlParsingNode.href;
  1397. }
  1398. urlParsingNode.setAttribute('href', href);
  1399. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1400. return {
  1401. href: urlParsingNode.href,
  1402. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1403. host: urlParsingNode.host,
  1404. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1405. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1406. hostname: urlParsingNode.hostname,
  1407. port: urlParsingNode.port,
  1408. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1409. urlParsingNode.pathname :
  1410. '/' + urlParsingNode.pathname
  1411. };
  1412. }
  1413. originURL = resolveURL(window.location.href);
  1414. /**
  1415. * Determine if a URL shares the same origin as the current location
  1416. *
  1417. * @param {String} requestURL The URL to test
  1418. * @returns {boolean} True if URL shares the same origin, otherwise false
  1419. */
  1420. return function isURLSameOrigin(requestURL) {
  1421. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1422. return (parsed.protocol === originURL.protocol &&
  1423. parsed.host === originURL.host);
  1424. };
  1425. })() :
  1426. // Non standard browser envs (web workers, react-native) lack needed support.
  1427. (function nonStandardBrowserEnv() {
  1428. return function isURLSameOrigin() {
  1429. return true;
  1430. };
  1431. })()
  1432. );
  1433. /***/ }),
  1434. /***/ "./lib/helpers/normalizeHeaderName.js":
  1435. /*!********************************************!*\
  1436. !*** ./lib/helpers/normalizeHeaderName.js ***!
  1437. \********************************************/
  1438. /*! no static exports found */
  1439. /***/ (function(module, exports, __webpack_require__) {
  1440. "use strict";
  1441. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  1442. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1443. utils.forEach(headers, function processHeader(value, name) {
  1444. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1445. headers[normalizedName] = value;
  1446. delete headers[name];
  1447. }
  1448. });
  1449. };
  1450. /***/ }),
  1451. /***/ "./lib/helpers/null.js":
  1452. /*!*****************************!*\
  1453. !*** ./lib/helpers/null.js ***!
  1454. \*****************************/
  1455. /*! no static exports found */
  1456. /***/ (function(module, exports) {
  1457. // eslint-disable-next-line strict
  1458. module.exports = null;
  1459. /***/ }),
  1460. /***/ "./lib/helpers/parseHeaders.js":
  1461. /*!*************************************!*\
  1462. !*** ./lib/helpers/parseHeaders.js ***!
  1463. \*************************************/
  1464. /*! no static exports found */
  1465. /***/ (function(module, exports, __webpack_require__) {
  1466. "use strict";
  1467. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1468. // Headers whose duplicates are ignored by node
  1469. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1470. var ignoreDuplicateOf = [
  1471. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1472. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1473. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1474. 'referer', 'retry-after', 'user-agent'
  1475. ];
  1476. /**
  1477. * Parse headers into an object
  1478. *
  1479. * ```
  1480. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1481. * Content-Type: application/json
  1482. * Connection: keep-alive
  1483. * Transfer-Encoding: chunked
  1484. * ```
  1485. *
  1486. * @param {String} headers Headers needing to be parsed
  1487. * @returns {Object} Headers parsed into an object
  1488. */
  1489. module.exports = function parseHeaders(headers) {
  1490. var parsed = {};
  1491. var key;
  1492. var val;
  1493. var i;
  1494. if (!headers) { return parsed; }
  1495. utils.forEach(headers.split('\n'), function parser(line) {
  1496. i = line.indexOf(':');
  1497. key = utils.trim(line.substr(0, i)).toLowerCase();
  1498. val = utils.trim(line.substr(i + 1));
  1499. if (key) {
  1500. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1501. return;
  1502. }
  1503. if (key === 'set-cookie') {
  1504. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1505. } else {
  1506. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1507. }
  1508. }
  1509. });
  1510. return parsed;
  1511. };
  1512. /***/ }),
  1513. /***/ "./lib/helpers/parseProtocol.js":
  1514. /*!**************************************!*\
  1515. !*** ./lib/helpers/parseProtocol.js ***!
  1516. \**************************************/
  1517. /*! no static exports found */
  1518. /***/ (function(module, exports, __webpack_require__) {
  1519. "use strict";
  1520. module.exports = function parseProtocol(url) {
  1521. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1522. return match && match[1] || '';
  1523. };
  1524. /***/ }),
  1525. /***/ "./lib/helpers/spread.js":
  1526. /*!*******************************!*\
  1527. !*** ./lib/helpers/spread.js ***!
  1528. \*******************************/
  1529. /*! no static exports found */
  1530. /***/ (function(module, exports, __webpack_require__) {
  1531. "use strict";
  1532. /**
  1533. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1534. *
  1535. * Common use case would be to use `Function.prototype.apply`.
  1536. *
  1537. * ```js
  1538. * function f(x, y, z) {}
  1539. * var args = [1, 2, 3];
  1540. * f.apply(null, args);
  1541. * ```
  1542. *
  1543. * With `spread` this example can be re-written.
  1544. *
  1545. * ```js
  1546. * spread(function(x, y, z) {})([1, 2, 3]);
  1547. * ```
  1548. *
  1549. * @param {Function} callback
  1550. * @returns {Function}
  1551. */
  1552. module.exports = function spread(callback) {
  1553. return function wrap(arr) {
  1554. return callback.apply(null, arr);
  1555. };
  1556. };
  1557. /***/ }),
  1558. /***/ "./lib/helpers/toFormData.js":
  1559. /*!***********************************!*\
  1560. !*** ./lib/helpers/toFormData.js ***!
  1561. \***********************************/
  1562. /*! no static exports found */
  1563. /***/ (function(module, exports, __webpack_require__) {
  1564. "use strict";
  1565. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  1566. /**
  1567. * Convert a data object to FormData
  1568. * @param {Object} obj
  1569. * @param {?Object} [formData]
  1570. * @returns {Object}
  1571. **/
  1572. function toFormData(obj, formData) {
  1573. // eslint-disable-next-line no-param-reassign
  1574. formData = formData || new FormData();
  1575. var stack = [];
  1576. function convertValue(value) {
  1577. if (value === null) return '';
  1578. if (utils.isDate(value)) {
  1579. return value.toISOString();
  1580. }
  1581. if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
  1582. return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  1583. }
  1584. return value;
  1585. }
  1586. function build(data, parentKey) {
  1587. if (utils.isPlainObject(data) || utils.isArray(data)) {
  1588. if (stack.indexOf(data) !== -1) {
  1589. throw Error('Circular reference detected in ' + parentKey);
  1590. }
  1591. stack.push(data);
  1592. utils.forEach(data, function each(value, key) {
  1593. if (utils.isUndefined(value)) return;
  1594. var fullKey = parentKey ? parentKey + '.' + key : key;
  1595. var arr;
  1596. if (value && !parentKey && typeof value === 'object') {
  1597. if (utils.endsWith(key, '{}')) {
  1598. // eslint-disable-next-line no-param-reassign
  1599. value = JSON.stringify(value);
  1600. } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
  1601. // eslint-disable-next-line func-names
  1602. arr.forEach(function(el) {
  1603. !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
  1604. });
  1605. return;
  1606. }
  1607. }
  1608. build(value, fullKey);
  1609. });
  1610. stack.pop();
  1611. } else {
  1612. formData.append(parentKey, convertValue(data));
  1613. }
  1614. }
  1615. build(obj);
  1616. return formData;
  1617. }
  1618. module.exports = toFormData;
  1619. /***/ }),
  1620. /***/ "./lib/helpers/validator.js":
  1621. /*!**********************************!*\
  1622. !*** ./lib/helpers/validator.js ***!
  1623. \**********************************/
  1624. /*! no static exports found */
  1625. /***/ (function(module, exports, __webpack_require__) {
  1626. "use strict";
  1627. var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
  1628. var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
  1629. var validators = {};
  1630. // eslint-disable-next-line func-names
  1631. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1632. validators[type] = function validator(thing) {
  1633. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1634. };
  1635. });
  1636. var deprecatedWarnings = {};
  1637. /**
  1638. * Transitional option validator
  1639. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  1640. * @param {string?} version - deprecated version / removed since version
  1641. * @param {string?} message - some message with additional info
  1642. * @returns {function}
  1643. */
  1644. validators.transitional = function transitional(validator, version, message) {
  1645. function formatMessage(opt, desc) {
  1646. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1647. }
  1648. // eslint-disable-next-line func-names
  1649. return function(value, opt, opts) {
  1650. if (validator === false) {
  1651. throw new AxiosError(
  1652. formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
  1653. AxiosError.ERR_DEPRECATED
  1654. );
  1655. }
  1656. if (version && !deprecatedWarnings[opt]) {
  1657. deprecatedWarnings[opt] = true;
  1658. // eslint-disable-next-line no-console
  1659. console.warn(
  1660. formatMessage(
  1661. opt,
  1662. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1663. )
  1664. );
  1665. }
  1666. return validator ? validator(value, opt, opts) : true;
  1667. };
  1668. };
  1669. /**
  1670. * Assert object's properties type
  1671. * @param {object} options
  1672. * @param {object} schema
  1673. * @param {boolean?} allowUnknown
  1674. */
  1675. function assertOptions(options, schema, allowUnknown) {
  1676. if (typeof options !== 'object') {
  1677. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  1678. }
  1679. var keys = Object.keys(options);
  1680. var i = keys.length;
  1681. while (i-- > 0) {
  1682. var opt = keys[i];
  1683. var validator = schema[opt];
  1684. if (validator) {
  1685. var value = options[opt];
  1686. var result = value === undefined || validator(value, opt, options);
  1687. if (result !== true) {
  1688. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  1689. }
  1690. continue;
  1691. }
  1692. if (allowUnknown !== true) {
  1693. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  1694. }
  1695. }
  1696. }
  1697. module.exports = {
  1698. assertOptions: assertOptions,
  1699. validators: validators
  1700. };
  1701. /***/ }),
  1702. /***/ "./lib/utils.js":
  1703. /*!**********************!*\
  1704. !*** ./lib/utils.js ***!
  1705. \**********************/
  1706. /*! no static exports found */
  1707. /***/ (function(module, exports, __webpack_require__) {
  1708. "use strict";
  1709. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  1710. // utils is a library of generic helper functions non-specific to axios
  1711. var toString = Object.prototype.toString;
  1712. // eslint-disable-next-line func-names
  1713. var kindOf = (function(cache) {
  1714. // eslint-disable-next-line func-names
  1715. return function(thing) {
  1716. var str = toString.call(thing);
  1717. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  1718. };
  1719. })(Object.create(null));
  1720. function kindOfTest(type) {
  1721. type = type.toLowerCase();
  1722. return function isKindOf(thing) {
  1723. return kindOf(thing) === type;
  1724. };
  1725. }
  1726. /**
  1727. * Determine if a value is an Array
  1728. *
  1729. * @param {Object} val The value to test
  1730. * @returns {boolean} True if value is an Array, otherwise false
  1731. */
  1732. function isArray(val) {
  1733. return Array.isArray(val);
  1734. }
  1735. /**
  1736. * Determine if a value is undefined
  1737. *
  1738. * @param {Object} val The value to test
  1739. * @returns {boolean} True if the value is undefined, otherwise false
  1740. */
  1741. function isUndefined(val) {
  1742. return typeof val === 'undefined';
  1743. }
  1744. /**
  1745. * Determine if a value is a Buffer
  1746. *
  1747. * @param {Object} val The value to test
  1748. * @returns {boolean} True if value is a Buffer, otherwise false
  1749. */
  1750. function isBuffer(val) {
  1751. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1752. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1753. }
  1754. /**
  1755. * Determine if a value is an ArrayBuffer
  1756. *
  1757. * @function
  1758. * @param {Object} val The value to test
  1759. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1760. */
  1761. var isArrayBuffer = kindOfTest('ArrayBuffer');
  1762. /**
  1763. * Determine if a value is a view on an ArrayBuffer
  1764. *
  1765. * @param {Object} val The value to test
  1766. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1767. */
  1768. function isArrayBufferView(val) {
  1769. var result;
  1770. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1771. result = ArrayBuffer.isView(val);
  1772. } else {
  1773. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  1774. }
  1775. return result;
  1776. }
  1777. /**
  1778. * Determine if a value is a String
  1779. *
  1780. * @param {Object} val The value to test
  1781. * @returns {boolean} True if value is a String, otherwise false
  1782. */
  1783. function isString(val) {
  1784. return typeof val === 'string';
  1785. }
  1786. /**
  1787. * Determine if a value is a Number
  1788. *
  1789. * @param {Object} val The value to test
  1790. * @returns {boolean} True if value is a Number, otherwise false
  1791. */
  1792. function isNumber(val) {
  1793. return typeof val === 'number';
  1794. }
  1795. /**
  1796. * Determine if a value is an Object
  1797. *
  1798. * @param {Object} val The value to test
  1799. * @returns {boolean} True if value is an Object, otherwise false
  1800. */
  1801. function isObject(val) {
  1802. return val !== null && typeof val === 'object';
  1803. }
  1804. /**
  1805. * Determine if a value is a plain Object
  1806. *
  1807. * @param {Object} val The value to test
  1808. * @return {boolean} True if value is a plain Object, otherwise false
  1809. */
  1810. function isPlainObject(val) {
  1811. if (kindOf(val) !== 'object') {
  1812. return false;
  1813. }
  1814. var prototype = Object.getPrototypeOf(val);
  1815. return prototype === null || prototype === Object.prototype;
  1816. }
  1817. /**
  1818. * Determine if a value is a Date
  1819. *
  1820. * @function
  1821. * @param {Object} val The value to test
  1822. * @returns {boolean} True if value is a Date, otherwise false
  1823. */
  1824. var isDate = kindOfTest('Date');
  1825. /**
  1826. * Determine if a value is a File
  1827. *
  1828. * @function
  1829. * @param {Object} val The value to test
  1830. * @returns {boolean} True if value is a File, otherwise false
  1831. */
  1832. var isFile = kindOfTest('File');
  1833. /**
  1834. * Determine if a value is a Blob
  1835. *
  1836. * @function
  1837. * @param {Object} val The value to test
  1838. * @returns {boolean} True if value is a Blob, otherwise false
  1839. */
  1840. var isBlob = kindOfTest('Blob');
  1841. /**
  1842. * Determine if a value is a FileList
  1843. *
  1844. * @function
  1845. * @param {Object} val The value to test
  1846. * @returns {boolean} True if value is a File, otherwise false
  1847. */
  1848. var isFileList = kindOfTest('FileList');
  1849. /**
  1850. * Determine if a value is a Function
  1851. *
  1852. * @param {Object} val The value to test
  1853. * @returns {boolean} True if value is a Function, otherwise false
  1854. */
  1855. function isFunction(val) {
  1856. return toString.call(val) === '[object Function]';
  1857. }
  1858. /**
  1859. * Determine if a value is a Stream
  1860. *
  1861. * @param {Object} val The value to test
  1862. * @returns {boolean} True if value is a Stream, otherwise false
  1863. */
  1864. function isStream(val) {
  1865. return isObject(val) && isFunction(val.pipe);
  1866. }
  1867. /**
  1868. * Determine if a value is a FormData
  1869. *
  1870. * @param {Object} thing The value to test
  1871. * @returns {boolean} True if value is an FormData, otherwise false
  1872. */
  1873. function isFormData(thing) {
  1874. var pattern = '[object FormData]';
  1875. return thing && (
  1876. (typeof FormData === 'function' && thing instanceof FormData) ||
  1877. toString.call(thing) === pattern ||
  1878. (isFunction(thing.toString) && thing.toString() === pattern)
  1879. );
  1880. }
  1881. /**
  1882. * Determine if a value is a URLSearchParams object
  1883. * @function
  1884. * @param {Object} val The value to test
  1885. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1886. */
  1887. var isURLSearchParams = kindOfTest('URLSearchParams');
  1888. /**
  1889. * Trim excess whitespace off the beginning and end of a string
  1890. *
  1891. * @param {String} str The String to trim
  1892. * @returns {String} The String freed of excess whitespace
  1893. */
  1894. function trim(str) {
  1895. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  1896. }
  1897. /**
  1898. * Determine if we're running in a standard browser environment
  1899. *
  1900. * This allows axios to run in a web worker, and react-native.
  1901. * Both environments support XMLHttpRequest, but not fully standard globals.
  1902. *
  1903. * web workers:
  1904. * typeof window -> undefined
  1905. * typeof document -> undefined
  1906. *
  1907. * react-native:
  1908. * navigator.product -> 'ReactNative'
  1909. * nativescript
  1910. * navigator.product -> 'NativeScript' or 'NS'
  1911. */
  1912. function isStandardBrowserEnv() {
  1913. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1914. navigator.product === 'NativeScript' ||
  1915. navigator.product === 'NS')) {
  1916. return false;
  1917. }
  1918. return (
  1919. typeof window !== 'undefined' &&
  1920. typeof document !== 'undefined'
  1921. );
  1922. }
  1923. /**
  1924. * Iterate over an Array or an Object invoking a function for each item.
  1925. *
  1926. * If `obj` is an Array callback will be called passing
  1927. * the value, index, and complete array for each item.
  1928. *
  1929. * If 'obj' is an Object callback will be called passing
  1930. * the value, key, and complete object for each property.
  1931. *
  1932. * @param {Object|Array} obj The object to iterate
  1933. * @param {Function} fn The callback to invoke for each item
  1934. */
  1935. function forEach(obj, fn) {
  1936. // Don't bother if no value provided
  1937. if (obj === null || typeof obj === 'undefined') {
  1938. return;
  1939. }
  1940. // Force an array if not already something iterable
  1941. if (typeof obj !== 'object') {
  1942. /*eslint no-param-reassign:0*/
  1943. obj = [obj];
  1944. }
  1945. if (isArray(obj)) {
  1946. // Iterate over array values
  1947. for (var i = 0, l = obj.length; i < l; i++) {
  1948. fn.call(null, obj[i], i, obj);
  1949. }
  1950. } else {
  1951. // Iterate over object keys
  1952. for (var key in obj) {
  1953. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1954. fn.call(null, obj[key], key, obj);
  1955. }
  1956. }
  1957. }
  1958. }
  1959. /**
  1960. * Accepts varargs expecting each argument to be an object, then
  1961. * immutably merges the properties of each object and returns result.
  1962. *
  1963. * When multiple objects contain the same key the later object in
  1964. * the arguments list will take precedence.
  1965. *
  1966. * Example:
  1967. *
  1968. * ```js
  1969. * var result = merge({foo: 123}, {foo: 456});
  1970. * console.log(result.foo); // outputs 456
  1971. * ```
  1972. *
  1973. * @param {Object} obj1 Object to merge
  1974. * @returns {Object} Result of all merge properties
  1975. */
  1976. function merge(/* obj1, obj2, obj3, ... */) {
  1977. var result = {};
  1978. function assignValue(val, key) {
  1979. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1980. result[key] = merge(result[key], val);
  1981. } else if (isPlainObject(val)) {
  1982. result[key] = merge({}, val);
  1983. } else if (isArray(val)) {
  1984. result[key] = val.slice();
  1985. } else {
  1986. result[key] = val;
  1987. }
  1988. }
  1989. for (var i = 0, l = arguments.length; i < l; i++) {
  1990. forEach(arguments[i], assignValue);
  1991. }
  1992. return result;
  1993. }
  1994. /**
  1995. * Extends object a by mutably adding to it the properties of object b.
  1996. *
  1997. * @param {Object} a The object to be extended
  1998. * @param {Object} b The object to copy properties from
  1999. * @param {Object} thisArg The object to bind function to
  2000. * @return {Object} The resulting value of object a
  2001. */
  2002. function extend(a, b, thisArg) {
  2003. forEach(b, function assignValue(val, key) {
  2004. if (thisArg && typeof val === 'function') {
  2005. a[key] = bind(val, thisArg);
  2006. } else {
  2007. a[key] = val;
  2008. }
  2009. });
  2010. return a;
  2011. }
  2012. /**
  2013. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  2014. *
  2015. * @param {string} content with BOM
  2016. * @return {string} content value without BOM
  2017. */
  2018. function stripBOM(content) {
  2019. if (content.charCodeAt(0) === 0xFEFF) {
  2020. content = content.slice(1);
  2021. }
  2022. return content;
  2023. }
  2024. /**
  2025. * Inherit the prototype methods from one constructor into another
  2026. * @param {function} constructor
  2027. * @param {function} superConstructor
  2028. * @param {object} [props]
  2029. * @param {object} [descriptors]
  2030. */
  2031. function inherits(constructor, superConstructor, props, descriptors) {
  2032. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  2033. constructor.prototype.constructor = constructor;
  2034. props && Object.assign(constructor.prototype, props);
  2035. }
  2036. /**
  2037. * Resolve object with deep prototype chain to a flat object
  2038. * @param {Object} sourceObj source object
  2039. * @param {Object} [destObj]
  2040. * @param {Function} [filter]
  2041. * @returns {Object}
  2042. */
  2043. function toFlatObject(sourceObj, destObj, filter) {
  2044. var props;
  2045. var i;
  2046. var prop;
  2047. var merged = {};
  2048. destObj = destObj || {};
  2049. do {
  2050. props = Object.getOwnPropertyNames(sourceObj);
  2051. i = props.length;
  2052. while (i-- > 0) {
  2053. prop = props[i];
  2054. if (!merged[prop]) {
  2055. destObj[prop] = sourceObj[prop];
  2056. merged[prop] = true;
  2057. }
  2058. }
  2059. sourceObj = Object.getPrototypeOf(sourceObj);
  2060. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  2061. return destObj;
  2062. }
  2063. /*
  2064. * determines whether a string ends with the characters of a specified string
  2065. * @param {String} str
  2066. * @param {String} searchString
  2067. * @param {Number} [position= 0]
  2068. * @returns {boolean}
  2069. */
  2070. function endsWith(str, searchString, position) {
  2071. str = String(str);
  2072. if (position === undefined || position > str.length) {
  2073. position = str.length;
  2074. }
  2075. position -= searchString.length;
  2076. var lastIndex = str.indexOf(searchString, position);
  2077. return lastIndex !== -1 && lastIndex === position;
  2078. }
  2079. /**
  2080. * Returns new array from array like object
  2081. * @param {*} [thing]
  2082. * @returns {Array}
  2083. */
  2084. function toArray(thing) {
  2085. if (!thing) return null;
  2086. var i = thing.length;
  2087. if (isUndefined(i)) return null;
  2088. var arr = new Array(i);
  2089. while (i-- > 0) {
  2090. arr[i] = thing[i];
  2091. }
  2092. return arr;
  2093. }
  2094. // eslint-disable-next-line func-names
  2095. var isTypedArray = (function(TypedArray) {
  2096. // eslint-disable-next-line func-names
  2097. return function(thing) {
  2098. return TypedArray && thing instanceof TypedArray;
  2099. };
  2100. })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
  2101. module.exports = {
  2102. isArray: isArray,
  2103. isArrayBuffer: isArrayBuffer,
  2104. isBuffer: isBuffer,
  2105. isFormData: isFormData,
  2106. isArrayBufferView: isArrayBufferView,
  2107. isString: isString,
  2108. isNumber: isNumber,
  2109. isObject: isObject,
  2110. isPlainObject: isPlainObject,
  2111. isUndefined: isUndefined,
  2112. isDate: isDate,
  2113. isFile: isFile,
  2114. isBlob: isBlob,
  2115. isFunction: isFunction,
  2116. isStream: isStream,
  2117. isURLSearchParams: isURLSearchParams,
  2118. isStandardBrowserEnv: isStandardBrowserEnv,
  2119. forEach: forEach,
  2120. merge: merge,
  2121. extend: extend,
  2122. trim: trim,
  2123. stripBOM: stripBOM,
  2124. inherits: inherits,
  2125. toFlatObject: toFlatObject,
  2126. kindOf: kindOf,
  2127. kindOfTest: kindOfTest,
  2128. endsWith: endsWith,
  2129. toArray: toArray,
  2130. isTypedArray: isTypedArray,
  2131. isFileList: isFileList
  2132. };
  2133. /***/ })
  2134. /******/ });
  2135. });
  2136. //# sourceMappingURL=axios.map