axios.js 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193
  1. /* axios v0.21.4 | (c) 2021 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. })(window, 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 createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
  122. module.exports = function xhrAdapter(config) {
  123. return new Promise(function dispatchXhrRequest(resolve, reject) {
  124. var requestData = config.data;
  125. var requestHeaders = config.headers;
  126. var responseType = config.responseType;
  127. if (utils.isFormData(requestData)) {
  128. delete requestHeaders['Content-Type']; // Let the browser set it
  129. }
  130. var request = new XMLHttpRequest();
  131. // HTTP basic authentication
  132. if (config.auth) {
  133. var username = config.auth.username || '';
  134. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  135. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  136. }
  137. var fullPath = buildFullPath(config.baseURL, config.url);
  138. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  139. // Set the request timeout in MS
  140. request.timeout = config.timeout;
  141. function onloadend() {
  142. if (!request) {
  143. return;
  144. }
  145. // Prepare the response
  146. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  147. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  148. request.responseText : request.response;
  149. var response = {
  150. data: responseData,
  151. status: request.status,
  152. statusText: request.statusText,
  153. headers: responseHeaders,
  154. config: config,
  155. request: request
  156. };
  157. settle(resolve, reject, response);
  158. // Clean up request
  159. request = null;
  160. }
  161. if ('onloadend' in request) {
  162. // Use onloadend if available
  163. request.onloadend = onloadend;
  164. } else {
  165. // Listen for ready state to emulate onloadend
  166. request.onreadystatechange = function handleLoad() {
  167. if (!request || request.readyState !== 4) {
  168. return;
  169. }
  170. // The request errored out and we didn't get a response, this will be
  171. // handled by onerror instead
  172. // With one exception: request that using file: protocol, most browsers
  173. // will return status as 0 even though it's a successful request
  174. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  175. return;
  176. }
  177. // readystate handler is calling before onerror or ontimeout handlers,
  178. // so we should call onloadend on the next 'tick'
  179. setTimeout(onloadend);
  180. };
  181. }
  182. // Handle browser request cancellation (as opposed to a manual cancellation)
  183. request.onabort = function handleAbort() {
  184. if (!request) {
  185. return;
  186. }
  187. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  188. // Clean up request
  189. request = null;
  190. };
  191. // Handle low level network errors
  192. request.onerror = function handleError() {
  193. // Real errors are hidden from us by the browser
  194. // onerror should only fire if it's a network error
  195. reject(createError('Network Error', config, null, request));
  196. // Clean up request
  197. request = null;
  198. };
  199. // Handle timeout
  200. request.ontimeout = function handleTimeout() {
  201. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  202. if (config.timeoutErrorMessage) {
  203. timeoutErrorMessage = config.timeoutErrorMessage;
  204. }
  205. reject(createError(
  206. timeoutErrorMessage,
  207. config,
  208. config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  209. request));
  210. // Clean up request
  211. request = null;
  212. };
  213. // Add xsrf header
  214. // This is only done if running in a standard browser environment.
  215. // Specifically not if we're in a web worker, or react-native.
  216. if (utils.isStandardBrowserEnv()) {
  217. // Add xsrf header
  218. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  219. cookies.read(config.xsrfCookieName) :
  220. undefined;
  221. if (xsrfValue) {
  222. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  223. }
  224. }
  225. // Add headers to the request
  226. if ('setRequestHeader' in request) {
  227. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  228. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  229. // Remove Content-Type if data is undefined
  230. delete requestHeaders[key];
  231. } else {
  232. // Otherwise add header to the request
  233. request.setRequestHeader(key, val);
  234. }
  235. });
  236. }
  237. // Add withCredentials to request if needed
  238. if (!utils.isUndefined(config.withCredentials)) {
  239. request.withCredentials = !!config.withCredentials;
  240. }
  241. // Add responseType to request if needed
  242. if (responseType && responseType !== 'json') {
  243. request.responseType = config.responseType;
  244. }
  245. // Handle progress if needed
  246. if (typeof config.onDownloadProgress === 'function') {
  247. request.addEventListener('progress', config.onDownloadProgress);
  248. }
  249. // Not all browsers support upload events
  250. if (typeof config.onUploadProgress === 'function' && request.upload) {
  251. request.upload.addEventListener('progress', config.onUploadProgress);
  252. }
  253. if (config.cancelToken) {
  254. // Handle cancellation
  255. config.cancelToken.promise.then(function onCanceled(cancel) {
  256. if (!request) {
  257. return;
  258. }
  259. request.abort();
  260. reject(cancel);
  261. // Clean up request
  262. request = null;
  263. });
  264. }
  265. if (!requestData) {
  266. requestData = null;
  267. }
  268. // Send the request
  269. request.send(requestData);
  270. });
  271. };
  272. /***/ }),
  273. /***/ "./lib/axios.js":
  274. /*!**********************!*\
  275. !*** ./lib/axios.js ***!
  276. \**********************/
  277. /*! no static exports found */
  278. /***/ (function(module, exports, __webpack_require__) {
  279. "use strict";
  280. var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
  281. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  282. var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
  283. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
  284. var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults.js");
  285. /**
  286. * Create an instance of Axios
  287. *
  288. * @param {Object} defaultConfig The default config for the instance
  289. * @return {Axios} A new instance of Axios
  290. */
  291. function createInstance(defaultConfig) {
  292. var context = new Axios(defaultConfig);
  293. var instance = bind(Axios.prototype.request, context);
  294. // Copy axios.prototype to instance
  295. utils.extend(instance, Axios.prototype, context);
  296. // Copy context to instance
  297. utils.extend(instance, context);
  298. return instance;
  299. }
  300. // Create the default instance to be exported
  301. var axios = createInstance(defaults);
  302. // Expose Axios class to allow class inheritance
  303. axios.Axios = Axios;
  304. // Factory for creating new instances
  305. axios.create = function create(instanceConfig) {
  306. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  307. };
  308. // Expose Cancel & CancelToken
  309. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./lib/cancel/Cancel.js");
  310. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
  311. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
  312. // Expose all/spread
  313. axios.all = function all(promises) {
  314. return Promise.all(promises);
  315. };
  316. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./lib/helpers/spread.js");
  317. // Expose isAxiosError
  318. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./lib/helpers/isAxiosError.js");
  319. module.exports = axios;
  320. // Allow use of default import syntax in TypeScript
  321. module.exports.default = axios;
  322. /***/ }),
  323. /***/ "./lib/cancel/Cancel.js":
  324. /*!******************************!*\
  325. !*** ./lib/cancel/Cancel.js ***!
  326. \******************************/
  327. /*! no static exports found */
  328. /***/ (function(module, exports, __webpack_require__) {
  329. "use strict";
  330. /**
  331. * A `Cancel` is an object that is thrown when an operation is canceled.
  332. *
  333. * @class
  334. * @param {string=} message The message.
  335. */
  336. function Cancel(message) {
  337. this.message = message;
  338. }
  339. Cancel.prototype.toString = function toString() {
  340. return 'Cancel' + (this.message ? ': ' + this.message : '');
  341. };
  342. Cancel.prototype.__CANCEL__ = true;
  343. module.exports = Cancel;
  344. /***/ }),
  345. /***/ "./lib/cancel/CancelToken.js":
  346. /*!***********************************!*\
  347. !*** ./lib/cancel/CancelToken.js ***!
  348. \***********************************/
  349. /*! no static exports found */
  350. /***/ (function(module, exports, __webpack_require__) {
  351. "use strict";
  352. var Cancel = __webpack_require__(/*! ./Cancel */ "./lib/cancel/Cancel.js");
  353. /**
  354. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  355. *
  356. * @class
  357. * @param {Function} executor The executor function.
  358. */
  359. function CancelToken(executor) {
  360. if (typeof executor !== 'function') {
  361. throw new TypeError('executor must be a function.');
  362. }
  363. var resolvePromise;
  364. this.promise = new Promise(function promiseExecutor(resolve) {
  365. resolvePromise = resolve;
  366. });
  367. var token = this;
  368. executor(function cancel(message) {
  369. if (token.reason) {
  370. // Cancellation has already been requested
  371. return;
  372. }
  373. token.reason = new Cancel(message);
  374. resolvePromise(token.reason);
  375. });
  376. }
  377. /**
  378. * Throws a `Cancel` if cancellation has been requested.
  379. */
  380. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  381. if (this.reason) {
  382. throw this.reason;
  383. }
  384. };
  385. /**
  386. * Returns an object that contains a new `CancelToken` and a function that, when called,
  387. * cancels the `CancelToken`.
  388. */
  389. CancelToken.source = function source() {
  390. var cancel;
  391. var token = new CancelToken(function executor(c) {
  392. cancel = c;
  393. });
  394. return {
  395. token: token,
  396. cancel: cancel
  397. };
  398. };
  399. module.exports = CancelToken;
  400. /***/ }),
  401. /***/ "./lib/cancel/isCancel.js":
  402. /*!********************************!*\
  403. !*** ./lib/cancel/isCancel.js ***!
  404. \********************************/
  405. /*! no static exports found */
  406. /***/ (function(module, exports, __webpack_require__) {
  407. "use strict";
  408. module.exports = function isCancel(value) {
  409. return !!(value && value.__CANCEL__);
  410. };
  411. /***/ }),
  412. /***/ "./lib/core/Axios.js":
  413. /*!***************************!*\
  414. !*** ./lib/core/Axios.js ***!
  415. \***************************/
  416. /*! no static exports found */
  417. /***/ (function(module, exports, __webpack_require__) {
  418. "use strict";
  419. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  420. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/buildURL.js");
  421. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
  422. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
  423. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
  424. var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
  425. var validators = validator.validators;
  426. /**
  427. * Create a new instance of Axios
  428. *
  429. * @param {Object} instanceConfig The default config for the instance
  430. */
  431. function Axios(instanceConfig) {
  432. this.defaults = instanceConfig;
  433. this.interceptors = {
  434. request: new InterceptorManager(),
  435. response: new InterceptorManager()
  436. };
  437. }
  438. /**
  439. * Dispatch a request
  440. *
  441. * @param {Object} config The config specific for this request (merged with this.defaults)
  442. */
  443. Axios.prototype.request = function request(config) {
  444. /*eslint no-param-reassign:0*/
  445. // Allow for axios('example/url'[, config]) a la fetch API
  446. if (typeof config === 'string') {
  447. config = arguments[1] || {};
  448. config.url = arguments[0];
  449. } else {
  450. config = config || {};
  451. }
  452. config = mergeConfig(this.defaults, config);
  453. // Set config.method
  454. if (config.method) {
  455. config.method = config.method.toLowerCase();
  456. } else if (this.defaults.method) {
  457. config.method = this.defaults.method.toLowerCase();
  458. } else {
  459. config.method = 'get';
  460. }
  461. var transitional = config.transitional;
  462. if (transitional !== undefined) {
  463. validator.assertOptions(transitional, {
  464. silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  465. forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  466. clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
  467. }, false);
  468. }
  469. // filter out skipped interceptors
  470. var requestInterceptorChain = [];
  471. var synchronousRequestInterceptors = true;
  472. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  473. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  474. return;
  475. }
  476. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  477. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  478. });
  479. var responseInterceptorChain = [];
  480. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  481. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  482. });
  483. var promise;
  484. if (!synchronousRequestInterceptors) {
  485. var chain = [dispatchRequest, undefined];
  486. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  487. chain = chain.concat(responseInterceptorChain);
  488. promise = Promise.resolve(config);
  489. while (chain.length) {
  490. promise = promise.then(chain.shift(), chain.shift());
  491. }
  492. return promise;
  493. }
  494. var newConfig = config;
  495. while (requestInterceptorChain.length) {
  496. var onFulfilled = requestInterceptorChain.shift();
  497. var onRejected = requestInterceptorChain.shift();
  498. try {
  499. newConfig = onFulfilled(newConfig);
  500. } catch (error) {
  501. onRejected(error);
  502. break;
  503. }
  504. }
  505. try {
  506. promise = dispatchRequest(newConfig);
  507. } catch (error) {
  508. return Promise.reject(error);
  509. }
  510. while (responseInterceptorChain.length) {
  511. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  512. }
  513. return promise;
  514. };
  515. Axios.prototype.getUri = function getUri(config) {
  516. config = mergeConfig(this.defaults, config);
  517. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  518. };
  519. // Provide aliases for supported request methods
  520. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  521. /*eslint func-names:0*/
  522. Axios.prototype[method] = function(url, config) {
  523. return this.request(mergeConfig(config || {}, {
  524. method: method,
  525. url: url,
  526. data: (config || {}).data
  527. }));
  528. };
  529. });
  530. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  531. /*eslint func-names:0*/
  532. Axios.prototype[method] = function(url, data, config) {
  533. return this.request(mergeConfig(config || {}, {
  534. method: method,
  535. url: url,
  536. data: data
  537. }));
  538. };
  539. });
  540. module.exports = Axios;
  541. /***/ }),
  542. /***/ "./lib/core/InterceptorManager.js":
  543. /*!****************************************!*\
  544. !*** ./lib/core/InterceptorManager.js ***!
  545. \****************************************/
  546. /*! no static exports found */
  547. /***/ (function(module, exports, __webpack_require__) {
  548. "use strict";
  549. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  550. function InterceptorManager() {
  551. this.handlers = [];
  552. }
  553. /**
  554. * Add a new interceptor to the stack
  555. *
  556. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  557. * @param {Function} rejected The function to handle `reject` for a `Promise`
  558. *
  559. * @return {Number} An ID used to remove interceptor later
  560. */
  561. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  562. this.handlers.push({
  563. fulfilled: fulfilled,
  564. rejected: rejected,
  565. synchronous: options ? options.synchronous : false,
  566. runWhen: options ? options.runWhen : null
  567. });
  568. return this.handlers.length - 1;
  569. };
  570. /**
  571. * Remove an interceptor from the stack
  572. *
  573. * @param {Number} id The ID that was returned by `use`
  574. */
  575. InterceptorManager.prototype.eject = function eject(id) {
  576. if (this.handlers[id]) {
  577. this.handlers[id] = null;
  578. }
  579. };
  580. /**
  581. * Iterate over all the registered interceptors
  582. *
  583. * This method is particularly useful for skipping over any
  584. * interceptors that may have become `null` calling `eject`.
  585. *
  586. * @param {Function} fn The function to call for each interceptor
  587. */
  588. InterceptorManager.prototype.forEach = function forEach(fn) {
  589. utils.forEach(this.handlers, function forEachHandler(h) {
  590. if (h !== null) {
  591. fn(h);
  592. }
  593. });
  594. };
  595. module.exports = InterceptorManager;
  596. /***/ }),
  597. /***/ "./lib/core/buildFullPath.js":
  598. /*!***********************************!*\
  599. !*** ./lib/core/buildFullPath.js ***!
  600. \***********************************/
  601. /*! no static exports found */
  602. /***/ (function(module, exports, __webpack_require__) {
  603. "use strict";
  604. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./lib/helpers/isAbsoluteURL.js");
  605. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./lib/helpers/combineURLs.js");
  606. /**
  607. * Creates a new URL by combining the baseURL with the requestedURL,
  608. * only when the requestedURL is not already an absolute URL.
  609. * If the requestURL is absolute, this function returns the requestedURL untouched.
  610. *
  611. * @param {string} baseURL The base URL
  612. * @param {string} requestedURL Absolute or relative URL to combine
  613. * @returns {string} The combined full path
  614. */
  615. module.exports = function buildFullPath(baseURL, requestedURL) {
  616. if (baseURL && !isAbsoluteURL(requestedURL)) {
  617. return combineURLs(baseURL, requestedURL);
  618. }
  619. return requestedURL;
  620. };
  621. /***/ }),
  622. /***/ "./lib/core/createError.js":
  623. /*!*********************************!*\
  624. !*** ./lib/core/createError.js ***!
  625. \*********************************/
  626. /*! no static exports found */
  627. /***/ (function(module, exports, __webpack_require__) {
  628. "use strict";
  629. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./lib/core/enhanceError.js");
  630. /**
  631. * Create an Error with the specified message, config, error code, request and response.
  632. *
  633. * @param {string} message The error message.
  634. * @param {Object} config The config.
  635. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  636. * @param {Object} [request] The request.
  637. * @param {Object} [response] The response.
  638. * @returns {Error} The created error.
  639. */
  640. module.exports = function createError(message, config, code, request, response) {
  641. var error = new Error(message);
  642. return enhanceError(error, config, code, request, response);
  643. };
  644. /***/ }),
  645. /***/ "./lib/core/dispatchRequest.js":
  646. /*!*************************************!*\
  647. !*** ./lib/core/dispatchRequest.js ***!
  648. \*************************************/
  649. /*! no static exports found */
  650. /***/ (function(module, exports, __webpack_require__) {
  651. "use strict";
  652. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  653. var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
  654. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
  655. var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
  656. /**
  657. * Throws a `Cancel` if cancellation has been requested.
  658. */
  659. function throwIfCancellationRequested(config) {
  660. if (config.cancelToken) {
  661. config.cancelToken.throwIfRequested();
  662. }
  663. }
  664. /**
  665. * Dispatch a request to the server using the configured adapter.
  666. *
  667. * @param {object} config The config that is to be used for the request
  668. * @returns {Promise} The Promise to be fulfilled
  669. */
  670. module.exports = function dispatchRequest(config) {
  671. throwIfCancellationRequested(config);
  672. // Ensure headers exist
  673. config.headers = config.headers || {};
  674. // Transform request data
  675. config.data = transformData.call(
  676. config,
  677. config.data,
  678. config.headers,
  679. config.transformRequest
  680. );
  681. // Flatten headers
  682. config.headers = utils.merge(
  683. config.headers.common || {},
  684. config.headers[config.method] || {},
  685. config.headers
  686. );
  687. utils.forEach(
  688. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  689. function cleanHeaderConfig(method) {
  690. delete config.headers[method];
  691. }
  692. );
  693. var adapter = config.adapter || defaults.adapter;
  694. return adapter(config).then(function onAdapterResolution(response) {
  695. throwIfCancellationRequested(config);
  696. // Transform response data
  697. response.data = transformData.call(
  698. config,
  699. response.data,
  700. response.headers,
  701. config.transformResponse
  702. );
  703. return response;
  704. }, function onAdapterRejection(reason) {
  705. if (!isCancel(reason)) {
  706. throwIfCancellationRequested(config);
  707. // Transform response data
  708. if (reason && reason.response) {
  709. reason.response.data = transformData.call(
  710. config,
  711. reason.response.data,
  712. reason.response.headers,
  713. config.transformResponse
  714. );
  715. }
  716. }
  717. return Promise.reject(reason);
  718. });
  719. };
  720. /***/ }),
  721. /***/ "./lib/core/enhanceError.js":
  722. /*!**********************************!*\
  723. !*** ./lib/core/enhanceError.js ***!
  724. \**********************************/
  725. /*! no static exports found */
  726. /***/ (function(module, exports, __webpack_require__) {
  727. "use strict";
  728. /**
  729. * Update an Error with the specified config, error code, and response.
  730. *
  731. * @param {Error} error The error to update.
  732. * @param {Object} config The config.
  733. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  734. * @param {Object} [request] The request.
  735. * @param {Object} [response] The response.
  736. * @returns {Error} The error.
  737. */
  738. module.exports = function enhanceError(error, config, code, request, response) {
  739. error.config = config;
  740. if (code) {
  741. error.code = code;
  742. }
  743. error.request = request;
  744. error.response = response;
  745. error.isAxiosError = true;
  746. error.toJSON = function toJSON() {
  747. return {
  748. // Standard
  749. message: this.message,
  750. name: this.name,
  751. // Microsoft
  752. description: this.description,
  753. number: this.number,
  754. // Mozilla
  755. fileName: this.fileName,
  756. lineNumber: this.lineNumber,
  757. columnNumber: this.columnNumber,
  758. stack: this.stack,
  759. // Axios
  760. config: this.config,
  761. code: this.code
  762. };
  763. };
  764. return error;
  765. };
  766. /***/ }),
  767. /***/ "./lib/core/mergeConfig.js":
  768. /*!*********************************!*\
  769. !*** ./lib/core/mergeConfig.js ***!
  770. \*********************************/
  771. /*! no static exports found */
  772. /***/ (function(module, exports, __webpack_require__) {
  773. "use strict";
  774. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  775. /**
  776. * Config-specific merge-function which creates a new config-object
  777. * by merging two configuration objects together.
  778. *
  779. * @param {Object} config1
  780. * @param {Object} config2
  781. * @returns {Object} New object resulting from merging config2 to config1
  782. */
  783. module.exports = function mergeConfig(config1, config2) {
  784. // eslint-disable-next-line no-param-reassign
  785. config2 = config2 || {};
  786. var config = {};
  787. var valueFromConfig2Keys = ['url', 'method', 'data'];
  788. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  789. var defaultToConfig2Keys = [
  790. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  791. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  792. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  793. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  794. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  795. ];
  796. var directMergeKeys = ['validateStatus'];
  797. function getMergedValue(target, source) {
  798. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  799. return utils.merge(target, source);
  800. } else if (utils.isPlainObject(source)) {
  801. return utils.merge({}, source);
  802. } else if (utils.isArray(source)) {
  803. return source.slice();
  804. }
  805. return source;
  806. }
  807. function mergeDeepProperties(prop) {
  808. if (!utils.isUndefined(config2[prop])) {
  809. config[prop] = getMergedValue(config1[prop], config2[prop]);
  810. } else if (!utils.isUndefined(config1[prop])) {
  811. config[prop] = getMergedValue(undefined, config1[prop]);
  812. }
  813. }
  814. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  815. if (!utils.isUndefined(config2[prop])) {
  816. config[prop] = getMergedValue(undefined, config2[prop]);
  817. }
  818. });
  819. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  820. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  821. if (!utils.isUndefined(config2[prop])) {
  822. config[prop] = getMergedValue(undefined, config2[prop]);
  823. } else if (!utils.isUndefined(config1[prop])) {
  824. config[prop] = getMergedValue(undefined, config1[prop]);
  825. }
  826. });
  827. utils.forEach(directMergeKeys, function merge(prop) {
  828. if (prop in config2) {
  829. config[prop] = getMergedValue(config1[prop], config2[prop]);
  830. } else if (prop in config1) {
  831. config[prop] = getMergedValue(undefined, config1[prop]);
  832. }
  833. });
  834. var axiosKeys = valueFromConfig2Keys
  835. .concat(mergeDeepPropertiesKeys)
  836. .concat(defaultToConfig2Keys)
  837. .concat(directMergeKeys);
  838. var otherKeys = Object
  839. .keys(config1)
  840. .concat(Object.keys(config2))
  841. .filter(function filterAxiosKeys(key) {
  842. return axiosKeys.indexOf(key) === -1;
  843. });
  844. utils.forEach(otherKeys, mergeDeepProperties);
  845. return config;
  846. };
  847. /***/ }),
  848. /***/ "./lib/core/settle.js":
  849. /*!****************************!*\
  850. !*** ./lib/core/settle.js ***!
  851. \****************************/
  852. /*! no static exports found */
  853. /***/ (function(module, exports, __webpack_require__) {
  854. "use strict";
  855. var createError = __webpack_require__(/*! ./createError */ "./lib/core/createError.js");
  856. /**
  857. * Resolve or reject a Promise based on response status.
  858. *
  859. * @param {Function} resolve A function that resolves the promise.
  860. * @param {Function} reject A function that rejects the promise.
  861. * @param {object} response The response.
  862. */
  863. module.exports = function settle(resolve, reject, response) {
  864. var validateStatus = response.config.validateStatus;
  865. if (!response.status || !validateStatus || validateStatus(response.status)) {
  866. resolve(response);
  867. } else {
  868. reject(createError(
  869. 'Request failed with status code ' + response.status,
  870. response.config,
  871. null,
  872. response.request,
  873. response
  874. ));
  875. }
  876. };
  877. /***/ }),
  878. /***/ "./lib/core/transformData.js":
  879. /*!***********************************!*\
  880. !*** ./lib/core/transformData.js ***!
  881. \***********************************/
  882. /*! no static exports found */
  883. /***/ (function(module, exports, __webpack_require__) {
  884. "use strict";
  885. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  886. var defaults = __webpack_require__(/*! ./../defaults */ "./lib/defaults.js");
  887. /**
  888. * Transform the data for a request or a response
  889. *
  890. * @param {Object|String} data The data to be transformed
  891. * @param {Array} headers The headers for the request or response
  892. * @param {Array|Function} fns A single function or Array of functions
  893. * @returns {*} The resulting transformed data
  894. */
  895. module.exports = function transformData(data, headers, fns) {
  896. var context = this || defaults;
  897. /*eslint no-param-reassign:0*/
  898. utils.forEach(fns, function transform(fn) {
  899. data = fn.call(context, data, headers);
  900. });
  901. return data;
  902. };
  903. /***/ }),
  904. /***/ "./lib/defaults.js":
  905. /*!*************************!*\
  906. !*** ./lib/defaults.js ***!
  907. \*************************/
  908. /*! no static exports found */
  909. /***/ (function(module, exports, __webpack_require__) {
  910. "use strict";
  911. var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
  912. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
  913. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./lib/core/enhanceError.js");
  914. var DEFAULT_CONTENT_TYPE = {
  915. 'Content-Type': 'application/x-www-form-urlencoded'
  916. };
  917. function setContentTypeIfUnset(headers, value) {
  918. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  919. headers['Content-Type'] = value;
  920. }
  921. }
  922. function getDefaultAdapter() {
  923. var adapter;
  924. if (typeof XMLHttpRequest !== 'undefined') {
  925. // For browsers use XHR adapter
  926. adapter = __webpack_require__(/*! ./adapters/xhr */ "./lib/adapters/xhr.js");
  927. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  928. // For node use HTTP adapter
  929. adapter = __webpack_require__(/*! ./adapters/http */ "./lib/adapters/xhr.js");
  930. }
  931. return adapter;
  932. }
  933. function stringifySafely(rawValue, parser, encoder) {
  934. if (utils.isString(rawValue)) {
  935. try {
  936. (parser || JSON.parse)(rawValue);
  937. return utils.trim(rawValue);
  938. } catch (e) {
  939. if (e.name !== 'SyntaxError') {
  940. throw e;
  941. }
  942. }
  943. }
  944. return (encoder || JSON.stringify)(rawValue);
  945. }
  946. var defaults = {
  947. transitional: {
  948. silentJSONParsing: true,
  949. forcedJSONParsing: true,
  950. clarifyTimeoutError: false
  951. },
  952. adapter: getDefaultAdapter(),
  953. transformRequest: [function transformRequest(data, headers) {
  954. normalizeHeaderName(headers, 'Accept');
  955. normalizeHeaderName(headers, 'Content-Type');
  956. if (utils.isFormData(data) ||
  957. utils.isArrayBuffer(data) ||
  958. utils.isBuffer(data) ||
  959. utils.isStream(data) ||
  960. utils.isFile(data) ||
  961. utils.isBlob(data)
  962. ) {
  963. return data;
  964. }
  965. if (utils.isArrayBufferView(data)) {
  966. return data.buffer;
  967. }
  968. if (utils.isURLSearchParams(data)) {
  969. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  970. return data.toString();
  971. }
  972. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  973. setContentTypeIfUnset(headers, 'application/json');
  974. return stringifySafely(data);
  975. }
  976. return data;
  977. }],
  978. transformResponse: [function transformResponse(data) {
  979. var transitional = this.transitional;
  980. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  981. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  982. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  983. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  984. try {
  985. return JSON.parse(data);
  986. } catch (e) {
  987. if (strictJSONParsing) {
  988. if (e.name === 'SyntaxError') {
  989. throw enhanceError(e, this, 'E_JSON_PARSE');
  990. }
  991. throw e;
  992. }
  993. }
  994. }
  995. return data;
  996. }],
  997. /**
  998. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  999. * timeout is not created.
  1000. */
  1001. timeout: 0,
  1002. xsrfCookieName: 'XSRF-TOKEN',
  1003. xsrfHeaderName: 'X-XSRF-TOKEN',
  1004. maxContentLength: -1,
  1005. maxBodyLength: -1,
  1006. validateStatus: function validateStatus(status) {
  1007. return status >= 200 && status < 300;
  1008. }
  1009. };
  1010. defaults.headers = {
  1011. common: {
  1012. 'Accept': 'application/json, text/plain, */*'
  1013. }
  1014. };
  1015. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1016. defaults.headers[method] = {};
  1017. });
  1018. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1019. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1020. });
  1021. module.exports = defaults;
  1022. /***/ }),
  1023. /***/ "./lib/helpers/bind.js":
  1024. /*!*****************************!*\
  1025. !*** ./lib/helpers/bind.js ***!
  1026. \*****************************/
  1027. /*! no static exports found */
  1028. /***/ (function(module, exports, __webpack_require__) {
  1029. "use strict";
  1030. module.exports = function bind(fn, thisArg) {
  1031. return function wrap() {
  1032. var args = new Array(arguments.length);
  1033. for (var i = 0; i < args.length; i++) {
  1034. args[i] = arguments[i];
  1035. }
  1036. return fn.apply(thisArg, args);
  1037. };
  1038. };
  1039. /***/ }),
  1040. /***/ "./lib/helpers/buildURL.js":
  1041. /*!*********************************!*\
  1042. !*** ./lib/helpers/buildURL.js ***!
  1043. \*********************************/
  1044. /*! no static exports found */
  1045. /***/ (function(module, exports, __webpack_require__) {
  1046. "use strict";
  1047. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1048. function encode(val) {
  1049. return encodeURIComponent(val).
  1050. replace(/%3A/gi, ':').
  1051. replace(/%24/g, '$').
  1052. replace(/%2C/gi, ',').
  1053. replace(/%20/g, '+').
  1054. replace(/%5B/gi, '[').
  1055. replace(/%5D/gi, ']');
  1056. }
  1057. /**
  1058. * Build a URL by appending params to the end
  1059. *
  1060. * @param {string} url The base of the url (e.g., http://www.google.com)
  1061. * @param {object} [params] The params to be appended
  1062. * @returns {string} The formatted url
  1063. */
  1064. module.exports = function buildURL(url, params, paramsSerializer) {
  1065. /*eslint no-param-reassign:0*/
  1066. if (!params) {
  1067. return url;
  1068. }
  1069. var serializedParams;
  1070. if (paramsSerializer) {
  1071. serializedParams = paramsSerializer(params);
  1072. } else if (utils.isURLSearchParams(params)) {
  1073. serializedParams = params.toString();
  1074. } else {
  1075. var parts = [];
  1076. utils.forEach(params, function serialize(val, key) {
  1077. if (val === null || typeof val === 'undefined') {
  1078. return;
  1079. }
  1080. if (utils.isArray(val)) {
  1081. key = key + '[]';
  1082. } else {
  1083. val = [val];
  1084. }
  1085. utils.forEach(val, function parseValue(v) {
  1086. if (utils.isDate(v)) {
  1087. v = v.toISOString();
  1088. } else if (utils.isObject(v)) {
  1089. v = JSON.stringify(v);
  1090. }
  1091. parts.push(encode(key) + '=' + encode(v));
  1092. });
  1093. });
  1094. serializedParams = parts.join('&');
  1095. }
  1096. if (serializedParams) {
  1097. var hashmarkIndex = url.indexOf('#');
  1098. if (hashmarkIndex !== -1) {
  1099. url = url.slice(0, hashmarkIndex);
  1100. }
  1101. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1102. }
  1103. return url;
  1104. };
  1105. /***/ }),
  1106. /***/ "./lib/helpers/combineURLs.js":
  1107. /*!************************************!*\
  1108. !*** ./lib/helpers/combineURLs.js ***!
  1109. \************************************/
  1110. /*! no static exports found */
  1111. /***/ (function(module, exports, __webpack_require__) {
  1112. "use strict";
  1113. /**
  1114. * Creates a new URL by combining the specified URLs
  1115. *
  1116. * @param {string} baseURL The base URL
  1117. * @param {string} relativeURL The relative URL
  1118. * @returns {string} The combined URL
  1119. */
  1120. module.exports = function combineURLs(baseURL, relativeURL) {
  1121. return relativeURL
  1122. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1123. : baseURL;
  1124. };
  1125. /***/ }),
  1126. /***/ "./lib/helpers/cookies.js":
  1127. /*!********************************!*\
  1128. !*** ./lib/helpers/cookies.js ***!
  1129. \********************************/
  1130. /*! no static exports found */
  1131. /***/ (function(module, exports, __webpack_require__) {
  1132. "use strict";
  1133. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1134. module.exports = (
  1135. utils.isStandardBrowserEnv() ?
  1136. // Standard browser envs support document.cookie
  1137. (function standardBrowserEnv() {
  1138. return {
  1139. write: function write(name, value, expires, path, domain, secure) {
  1140. var cookie = [];
  1141. cookie.push(name + '=' + encodeURIComponent(value));
  1142. if (utils.isNumber(expires)) {
  1143. cookie.push('expires=' + new Date(expires).toGMTString());
  1144. }
  1145. if (utils.isString(path)) {
  1146. cookie.push('path=' + path);
  1147. }
  1148. if (utils.isString(domain)) {
  1149. cookie.push('domain=' + domain);
  1150. }
  1151. if (secure === true) {
  1152. cookie.push('secure');
  1153. }
  1154. document.cookie = cookie.join('; ');
  1155. },
  1156. read: function read(name) {
  1157. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1158. return (match ? decodeURIComponent(match[3]) : null);
  1159. },
  1160. remove: function remove(name) {
  1161. this.write(name, '', Date.now() - 86400000);
  1162. }
  1163. };
  1164. })() :
  1165. // Non standard browser env (web workers, react-native) lack needed support.
  1166. (function nonStandardBrowserEnv() {
  1167. return {
  1168. write: function write() {},
  1169. read: function read() { return null; },
  1170. remove: function remove() {}
  1171. };
  1172. })()
  1173. );
  1174. /***/ }),
  1175. /***/ "./lib/helpers/isAbsoluteURL.js":
  1176. /*!**************************************!*\
  1177. !*** ./lib/helpers/isAbsoluteURL.js ***!
  1178. \**************************************/
  1179. /*! no static exports found */
  1180. /***/ (function(module, exports, __webpack_require__) {
  1181. "use strict";
  1182. /**
  1183. * Determines whether the specified URL is absolute
  1184. *
  1185. * @param {string} url The URL to test
  1186. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1187. */
  1188. module.exports = function isAbsoluteURL(url) {
  1189. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1190. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1191. // by any combination of letters, digits, plus, period, or hyphen.
  1192. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1193. };
  1194. /***/ }),
  1195. /***/ "./lib/helpers/isAxiosError.js":
  1196. /*!*************************************!*\
  1197. !*** ./lib/helpers/isAxiosError.js ***!
  1198. \*************************************/
  1199. /*! no static exports found */
  1200. /***/ (function(module, exports, __webpack_require__) {
  1201. "use strict";
  1202. /**
  1203. * Determines whether the payload is an error thrown by Axios
  1204. *
  1205. * @param {*} payload The value to test
  1206. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1207. */
  1208. module.exports = function isAxiosError(payload) {
  1209. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1210. };
  1211. /***/ }),
  1212. /***/ "./lib/helpers/isURLSameOrigin.js":
  1213. /*!****************************************!*\
  1214. !*** ./lib/helpers/isURLSameOrigin.js ***!
  1215. \****************************************/
  1216. /*! no static exports found */
  1217. /***/ (function(module, exports, __webpack_require__) {
  1218. "use strict";
  1219. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1220. module.exports = (
  1221. utils.isStandardBrowserEnv() ?
  1222. // Standard browser envs have full support of the APIs needed to test
  1223. // whether the request URL is of the same origin as current location.
  1224. (function standardBrowserEnv() {
  1225. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1226. var urlParsingNode = document.createElement('a');
  1227. var originURL;
  1228. /**
  1229. * Parse a URL to discover it's components
  1230. *
  1231. * @param {String} url The URL to be parsed
  1232. * @returns {Object}
  1233. */
  1234. function resolveURL(url) {
  1235. var href = url;
  1236. if (msie) {
  1237. // IE needs attribute set twice to normalize properties
  1238. urlParsingNode.setAttribute('href', href);
  1239. href = urlParsingNode.href;
  1240. }
  1241. urlParsingNode.setAttribute('href', href);
  1242. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1243. return {
  1244. href: urlParsingNode.href,
  1245. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1246. host: urlParsingNode.host,
  1247. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1248. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1249. hostname: urlParsingNode.hostname,
  1250. port: urlParsingNode.port,
  1251. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1252. urlParsingNode.pathname :
  1253. '/' + urlParsingNode.pathname
  1254. };
  1255. }
  1256. originURL = resolveURL(window.location.href);
  1257. /**
  1258. * Determine if a URL shares the same origin as the current location
  1259. *
  1260. * @param {String} requestURL The URL to test
  1261. * @returns {boolean} True if URL shares the same origin, otherwise false
  1262. */
  1263. return function isURLSameOrigin(requestURL) {
  1264. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1265. return (parsed.protocol === originURL.protocol &&
  1266. parsed.host === originURL.host);
  1267. };
  1268. })() :
  1269. // Non standard browser envs (web workers, react-native) lack needed support.
  1270. (function nonStandardBrowserEnv() {
  1271. return function isURLSameOrigin() {
  1272. return true;
  1273. };
  1274. })()
  1275. );
  1276. /***/ }),
  1277. /***/ "./lib/helpers/normalizeHeaderName.js":
  1278. /*!********************************************!*\
  1279. !*** ./lib/helpers/normalizeHeaderName.js ***!
  1280. \********************************************/
  1281. /*! no static exports found */
  1282. /***/ (function(module, exports, __webpack_require__) {
  1283. "use strict";
  1284. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  1285. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1286. utils.forEach(headers, function processHeader(value, name) {
  1287. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1288. headers[normalizedName] = value;
  1289. delete headers[name];
  1290. }
  1291. });
  1292. };
  1293. /***/ }),
  1294. /***/ "./lib/helpers/parseHeaders.js":
  1295. /*!*************************************!*\
  1296. !*** ./lib/helpers/parseHeaders.js ***!
  1297. \*************************************/
  1298. /*! no static exports found */
  1299. /***/ (function(module, exports, __webpack_require__) {
  1300. "use strict";
  1301. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1302. // Headers whose duplicates are ignored by node
  1303. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1304. var ignoreDuplicateOf = [
  1305. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1306. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1307. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1308. 'referer', 'retry-after', 'user-agent'
  1309. ];
  1310. /**
  1311. * Parse headers into an object
  1312. *
  1313. * ```
  1314. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1315. * Content-Type: application/json
  1316. * Connection: keep-alive
  1317. * Transfer-Encoding: chunked
  1318. * ```
  1319. *
  1320. * @param {String} headers Headers needing to be parsed
  1321. * @returns {Object} Headers parsed into an object
  1322. */
  1323. module.exports = function parseHeaders(headers) {
  1324. var parsed = {};
  1325. var key;
  1326. var val;
  1327. var i;
  1328. if (!headers) { return parsed; }
  1329. utils.forEach(headers.split('\n'), function parser(line) {
  1330. i = line.indexOf(':');
  1331. key = utils.trim(line.substr(0, i)).toLowerCase();
  1332. val = utils.trim(line.substr(i + 1));
  1333. if (key) {
  1334. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1335. return;
  1336. }
  1337. if (key === 'set-cookie') {
  1338. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1339. } else {
  1340. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1341. }
  1342. }
  1343. });
  1344. return parsed;
  1345. };
  1346. /***/ }),
  1347. /***/ "./lib/helpers/spread.js":
  1348. /*!*******************************!*\
  1349. !*** ./lib/helpers/spread.js ***!
  1350. \*******************************/
  1351. /*! no static exports found */
  1352. /***/ (function(module, exports, __webpack_require__) {
  1353. "use strict";
  1354. /**
  1355. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1356. *
  1357. * Common use case would be to use `Function.prototype.apply`.
  1358. *
  1359. * ```js
  1360. * function f(x, y, z) {}
  1361. * var args = [1, 2, 3];
  1362. * f.apply(null, args);
  1363. * ```
  1364. *
  1365. * With `spread` this example can be re-written.
  1366. *
  1367. * ```js
  1368. * spread(function(x, y, z) {})([1, 2, 3]);
  1369. * ```
  1370. *
  1371. * @param {Function} callback
  1372. * @returns {Function}
  1373. */
  1374. module.exports = function spread(callback) {
  1375. return function wrap(arr) {
  1376. return callback.apply(null, arr);
  1377. };
  1378. };
  1379. /***/ }),
  1380. /***/ "./lib/helpers/validator.js":
  1381. /*!**********************************!*\
  1382. !*** ./lib/helpers/validator.js ***!
  1383. \**********************************/
  1384. /*! no static exports found */
  1385. /***/ (function(module, exports, __webpack_require__) {
  1386. "use strict";
  1387. var pkg = __webpack_require__(/*! ./../../package.json */ "./package.json");
  1388. var validators = {};
  1389. // eslint-disable-next-line func-names
  1390. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1391. validators[type] = function validator(thing) {
  1392. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1393. };
  1394. });
  1395. var deprecatedWarnings = {};
  1396. var currentVerArr = pkg.version.split('.');
  1397. /**
  1398. * Compare package versions
  1399. * @param {string} version
  1400. * @param {string?} thanVersion
  1401. * @returns {boolean}
  1402. */
  1403. function isOlderVersion(version, thanVersion) {
  1404. var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
  1405. var destVer = version.split('.');
  1406. for (var i = 0; i < 3; i++) {
  1407. if (pkgVersionArr[i] > destVer[i]) {
  1408. return true;
  1409. } else if (pkgVersionArr[i] < destVer[i]) {
  1410. return false;
  1411. }
  1412. }
  1413. return false;
  1414. }
  1415. /**
  1416. * Transitional option validator
  1417. * @param {function|boolean?} validator
  1418. * @param {string?} version
  1419. * @param {string} message
  1420. * @returns {function}
  1421. */
  1422. validators.transitional = function transitional(validator, version, message) {
  1423. var isDeprecated = version && isOlderVersion(version);
  1424. function formatMessage(opt, desc) {
  1425. return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1426. }
  1427. // eslint-disable-next-line func-names
  1428. return function(value, opt, opts) {
  1429. if (validator === false) {
  1430. throw new Error(formatMessage(opt, ' has been removed in ' + version));
  1431. }
  1432. if (isDeprecated && !deprecatedWarnings[opt]) {
  1433. deprecatedWarnings[opt] = true;
  1434. // eslint-disable-next-line no-console
  1435. console.warn(
  1436. formatMessage(
  1437. opt,
  1438. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1439. )
  1440. );
  1441. }
  1442. return validator ? validator(value, opt, opts) : true;
  1443. };
  1444. };
  1445. /**
  1446. * Assert object's properties type
  1447. * @param {object} options
  1448. * @param {object} schema
  1449. * @param {boolean?} allowUnknown
  1450. */
  1451. function assertOptions(options, schema, allowUnknown) {
  1452. if (typeof options !== 'object') {
  1453. throw new TypeError('options must be an object');
  1454. }
  1455. var keys = Object.keys(options);
  1456. var i = keys.length;
  1457. while (i-- > 0) {
  1458. var opt = keys[i];
  1459. var validator = schema[opt];
  1460. if (validator) {
  1461. var value = options[opt];
  1462. var result = value === undefined || validator(value, opt, options);
  1463. if (result !== true) {
  1464. throw new TypeError('option ' + opt + ' must be ' + result);
  1465. }
  1466. continue;
  1467. }
  1468. if (allowUnknown !== true) {
  1469. throw Error('Unknown option ' + opt);
  1470. }
  1471. }
  1472. }
  1473. module.exports = {
  1474. isOlderVersion: isOlderVersion,
  1475. assertOptions: assertOptions,
  1476. validators: validators
  1477. };
  1478. /***/ }),
  1479. /***/ "./lib/utils.js":
  1480. /*!**********************!*\
  1481. !*** ./lib/utils.js ***!
  1482. \**********************/
  1483. /*! no static exports found */
  1484. /***/ (function(module, exports, __webpack_require__) {
  1485. "use strict";
  1486. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  1487. // utils is a library of generic helper functions non-specific to axios
  1488. var toString = Object.prototype.toString;
  1489. /**
  1490. * Determine if a value is an Array
  1491. *
  1492. * @param {Object} val The value to test
  1493. * @returns {boolean} True if value is an Array, otherwise false
  1494. */
  1495. function isArray(val) {
  1496. return toString.call(val) === '[object Array]';
  1497. }
  1498. /**
  1499. * Determine if a value is undefined
  1500. *
  1501. * @param {Object} val The value to test
  1502. * @returns {boolean} True if the value is undefined, otherwise false
  1503. */
  1504. function isUndefined(val) {
  1505. return typeof val === 'undefined';
  1506. }
  1507. /**
  1508. * Determine if a value is a Buffer
  1509. *
  1510. * @param {Object} val The value to test
  1511. * @returns {boolean} True if value is a Buffer, otherwise false
  1512. */
  1513. function isBuffer(val) {
  1514. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1515. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1516. }
  1517. /**
  1518. * Determine if a value is an ArrayBuffer
  1519. *
  1520. * @param {Object} val The value to test
  1521. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1522. */
  1523. function isArrayBuffer(val) {
  1524. return toString.call(val) === '[object ArrayBuffer]';
  1525. }
  1526. /**
  1527. * Determine if a value is a FormData
  1528. *
  1529. * @param {Object} val The value to test
  1530. * @returns {boolean} True if value is an FormData, otherwise false
  1531. */
  1532. function isFormData(val) {
  1533. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1534. }
  1535. /**
  1536. * Determine if a value is a view on an ArrayBuffer
  1537. *
  1538. * @param {Object} val The value to test
  1539. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1540. */
  1541. function isArrayBufferView(val) {
  1542. var result;
  1543. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1544. result = ArrayBuffer.isView(val);
  1545. } else {
  1546. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1547. }
  1548. return result;
  1549. }
  1550. /**
  1551. * Determine if a value is a String
  1552. *
  1553. * @param {Object} val The value to test
  1554. * @returns {boolean} True if value is a String, otherwise false
  1555. */
  1556. function isString(val) {
  1557. return typeof val === 'string';
  1558. }
  1559. /**
  1560. * Determine if a value is a Number
  1561. *
  1562. * @param {Object} val The value to test
  1563. * @returns {boolean} True if value is a Number, otherwise false
  1564. */
  1565. function isNumber(val) {
  1566. return typeof val === 'number';
  1567. }
  1568. /**
  1569. * Determine if a value is an Object
  1570. *
  1571. * @param {Object} val The value to test
  1572. * @returns {boolean} True if value is an Object, otherwise false
  1573. */
  1574. function isObject(val) {
  1575. return val !== null && typeof val === 'object';
  1576. }
  1577. /**
  1578. * Determine if a value is a plain Object
  1579. *
  1580. * @param {Object} val The value to test
  1581. * @return {boolean} True if value is a plain Object, otherwise false
  1582. */
  1583. function isPlainObject(val) {
  1584. if (toString.call(val) !== '[object Object]') {
  1585. return false;
  1586. }
  1587. var prototype = Object.getPrototypeOf(val);
  1588. return prototype === null || prototype === Object.prototype;
  1589. }
  1590. /**
  1591. * Determine if a value is a Date
  1592. *
  1593. * @param {Object} val The value to test
  1594. * @returns {boolean} True if value is a Date, otherwise false
  1595. */
  1596. function isDate(val) {
  1597. return toString.call(val) === '[object Date]';
  1598. }
  1599. /**
  1600. * Determine if a value is a File
  1601. *
  1602. * @param {Object} val The value to test
  1603. * @returns {boolean} True if value is a File, otherwise false
  1604. */
  1605. function isFile(val) {
  1606. return toString.call(val) === '[object File]';
  1607. }
  1608. /**
  1609. * Determine if a value is a Blob
  1610. *
  1611. * @param {Object} val The value to test
  1612. * @returns {boolean} True if value is a Blob, otherwise false
  1613. */
  1614. function isBlob(val) {
  1615. return toString.call(val) === '[object Blob]';
  1616. }
  1617. /**
  1618. * Determine if a value is a Function
  1619. *
  1620. * @param {Object} val The value to test
  1621. * @returns {boolean} True if value is a Function, otherwise false
  1622. */
  1623. function isFunction(val) {
  1624. return toString.call(val) === '[object Function]';
  1625. }
  1626. /**
  1627. * Determine if a value is a Stream
  1628. *
  1629. * @param {Object} val The value to test
  1630. * @returns {boolean} True if value is a Stream, otherwise false
  1631. */
  1632. function isStream(val) {
  1633. return isObject(val) && isFunction(val.pipe);
  1634. }
  1635. /**
  1636. * Determine if a value is a URLSearchParams object
  1637. *
  1638. * @param {Object} val The value to test
  1639. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1640. */
  1641. function isURLSearchParams(val) {
  1642. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1643. }
  1644. /**
  1645. * Trim excess whitespace off the beginning and end of a string
  1646. *
  1647. * @param {String} str The String to trim
  1648. * @returns {String} The String freed of excess whitespace
  1649. */
  1650. function trim(str) {
  1651. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  1652. }
  1653. /**
  1654. * Determine if we're running in a standard browser environment
  1655. *
  1656. * This allows axios to run in a web worker, and react-native.
  1657. * Both environments support XMLHttpRequest, but not fully standard globals.
  1658. *
  1659. * web workers:
  1660. * typeof window -> undefined
  1661. * typeof document -> undefined
  1662. *
  1663. * react-native:
  1664. * navigator.product -> 'ReactNative'
  1665. * nativescript
  1666. * navigator.product -> 'NativeScript' or 'NS'
  1667. */
  1668. function isStandardBrowserEnv() {
  1669. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1670. navigator.product === 'NativeScript' ||
  1671. navigator.product === 'NS')) {
  1672. return false;
  1673. }
  1674. return (
  1675. typeof window !== 'undefined' &&
  1676. typeof document !== 'undefined'
  1677. );
  1678. }
  1679. /**
  1680. * Iterate over an Array or an Object invoking a function for each item.
  1681. *
  1682. * If `obj` is an Array callback will be called passing
  1683. * the value, index, and complete array for each item.
  1684. *
  1685. * If 'obj' is an Object callback will be called passing
  1686. * the value, key, and complete object for each property.
  1687. *
  1688. * @param {Object|Array} obj The object to iterate
  1689. * @param {Function} fn The callback to invoke for each item
  1690. */
  1691. function forEach(obj, fn) {
  1692. // Don't bother if no value provided
  1693. if (obj === null || typeof obj === 'undefined') {
  1694. return;
  1695. }
  1696. // Force an array if not already something iterable
  1697. if (typeof obj !== 'object') {
  1698. /*eslint no-param-reassign:0*/
  1699. obj = [obj];
  1700. }
  1701. if (isArray(obj)) {
  1702. // Iterate over array values
  1703. for (var i = 0, l = obj.length; i < l; i++) {
  1704. fn.call(null, obj[i], i, obj);
  1705. }
  1706. } else {
  1707. // Iterate over object keys
  1708. for (var key in obj) {
  1709. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1710. fn.call(null, obj[key], key, obj);
  1711. }
  1712. }
  1713. }
  1714. }
  1715. /**
  1716. * Accepts varargs expecting each argument to be an object, then
  1717. * immutably merges the properties of each object and returns result.
  1718. *
  1719. * When multiple objects contain the same key the later object in
  1720. * the arguments list will take precedence.
  1721. *
  1722. * Example:
  1723. *
  1724. * ```js
  1725. * var result = merge({foo: 123}, {foo: 456});
  1726. * console.log(result.foo); // outputs 456
  1727. * ```
  1728. *
  1729. * @param {Object} obj1 Object to merge
  1730. * @returns {Object} Result of all merge properties
  1731. */
  1732. function merge(/* obj1, obj2, obj3, ... */) {
  1733. var result = {};
  1734. function assignValue(val, key) {
  1735. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1736. result[key] = merge(result[key], val);
  1737. } else if (isPlainObject(val)) {
  1738. result[key] = merge({}, val);
  1739. } else if (isArray(val)) {
  1740. result[key] = val.slice();
  1741. } else {
  1742. result[key] = val;
  1743. }
  1744. }
  1745. for (var i = 0, l = arguments.length; i < l; i++) {
  1746. forEach(arguments[i], assignValue);
  1747. }
  1748. return result;
  1749. }
  1750. /**
  1751. * Extends object a by mutably adding to it the properties of object b.
  1752. *
  1753. * @param {Object} a The object to be extended
  1754. * @param {Object} b The object to copy properties from
  1755. * @param {Object} thisArg The object to bind function to
  1756. * @return {Object} The resulting value of object a
  1757. */
  1758. function extend(a, b, thisArg) {
  1759. forEach(b, function assignValue(val, key) {
  1760. if (thisArg && typeof val === 'function') {
  1761. a[key] = bind(val, thisArg);
  1762. } else {
  1763. a[key] = val;
  1764. }
  1765. });
  1766. return a;
  1767. }
  1768. /**
  1769. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1770. *
  1771. * @param {string} content with BOM
  1772. * @return {string} content value without BOM
  1773. */
  1774. function stripBOM(content) {
  1775. if (content.charCodeAt(0) === 0xFEFF) {
  1776. content = content.slice(1);
  1777. }
  1778. return content;
  1779. }
  1780. module.exports = {
  1781. isArray: isArray,
  1782. isArrayBuffer: isArrayBuffer,
  1783. isBuffer: isBuffer,
  1784. isFormData: isFormData,
  1785. isArrayBufferView: isArrayBufferView,
  1786. isString: isString,
  1787. isNumber: isNumber,
  1788. isObject: isObject,
  1789. isPlainObject: isPlainObject,
  1790. isUndefined: isUndefined,
  1791. isDate: isDate,
  1792. isFile: isFile,
  1793. isBlob: isBlob,
  1794. isFunction: isFunction,
  1795. isStream: isStream,
  1796. isURLSearchParams: isURLSearchParams,
  1797. isStandardBrowserEnv: isStandardBrowserEnv,
  1798. forEach: forEach,
  1799. merge: merge,
  1800. extend: extend,
  1801. trim: trim,
  1802. stripBOM: stripBOM
  1803. };
  1804. /***/ }),
  1805. /***/ "./package.json":
  1806. /*!**********************!*\
  1807. !*** ./package.json ***!
  1808. \**********************/
  1809. /*! exports provided: name, version, description, main, scripts, repository, keywords, author, license, bugs, homepage, devDependencies, browser, jsdelivr, unpkg, typings, dependencies, bundlesize, default */
  1810. /***/ (function(module) {
  1811. module.exports = JSON.parse("{\"name\":\"axios\",\"version\":\"0.21.4\",\"description\":\"Promise based HTTP client for the browser and node.js\",\"main\":\"index.js\",\"scripts\":{\"test\":\"grunt test\",\"start\":\"node ./sandbox/server.js\",\"build\":\"NODE_ENV=production grunt build\",\"preversion\":\"npm test\",\"version\":\"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json\",\"postversion\":\"git push && git push --tags\",\"examples\":\"node ./examples/server.js\",\"coveralls\":\"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"fix\":\"eslint --fix lib/**/*.js\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/axios/axios.git\"},\"keywords\":[\"xhr\",\"http\",\"ajax\",\"promise\",\"node\"],\"author\":\"Matt Zabriskie\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/axios/axios/issues\"},\"homepage\":\"https://axios-http.com\",\"devDependencies\":{\"coveralls\":\"^3.0.0\",\"es6-promise\":\"^4.2.4\",\"grunt\":\"^1.3.0\",\"grunt-banner\":\"^0.6.0\",\"grunt-cli\":\"^1.2.0\",\"grunt-contrib-clean\":\"^1.1.0\",\"grunt-contrib-watch\":\"^1.0.0\",\"grunt-eslint\":\"^23.0.0\",\"grunt-karma\":\"^4.0.0\",\"grunt-mocha-test\":\"^0.13.3\",\"grunt-ts\":\"^6.0.0-beta.19\",\"grunt-webpack\":\"^4.0.2\",\"istanbul-instrumenter-loader\":\"^1.0.0\",\"jasmine-core\":\"^2.4.1\",\"karma\":\"^6.3.2\",\"karma-chrome-launcher\":\"^3.1.0\",\"karma-firefox-launcher\":\"^2.1.0\",\"karma-jasmine\":\"^1.1.1\",\"karma-jasmine-ajax\":\"^0.1.13\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-sauce-launcher\":\"^4.3.6\",\"karma-sinon\":\"^1.0.5\",\"karma-sourcemap-loader\":\"^0.3.8\",\"karma-webpack\":\"^4.0.2\",\"load-grunt-tasks\":\"^3.5.2\",\"minimist\":\"^1.2.0\",\"mocha\":\"^8.2.1\",\"sinon\":\"^4.5.0\",\"terser-webpack-plugin\":\"^4.2.3\",\"typescript\":\"^4.0.5\",\"url-search-params\":\"^0.10.0\",\"webpack\":\"^4.44.2\",\"webpack-dev-server\":\"^3.11.0\"},\"browser\":{\"./lib/adapters/http.js\":\"./lib/adapters/xhr.js\"},\"jsdelivr\":\"dist/axios.min.js\",\"unpkg\":\"dist/axios.min.js\",\"typings\":\"./index.d.ts\",\"dependencies\":{\"follow-redirects\":\"^1.14.0\"},\"bundlesize\":[{\"path\":\"./dist/axios.min.js\",\"threshold\":\"5kB\"}]}");
  1812. /***/ })
  1813. /******/ });
  1814. });
  1815. //# sourceMappingURL=axios.map