axios.js 62 KB

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