axios.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715
  1. /* axios v0.19.2 | (c) 2020 by Matt Zabriskie */
  2. (function webpackUniversalModuleDefinition(root, factory) {
  3. if(typeof exports === 'object' && typeof module === 'object')
  4. module.exports = factory();
  5. else if(typeof define === 'function' && define.amd)
  6. define([], factory);
  7. else if(typeof exports === 'object')
  8. exports["axios"] = factory();
  9. else
  10. root["axios"] = factory();
  11. })(this, function() {
  12. return /******/ (function(modules) { // webpackBootstrap
  13. /******/ // The module cache
  14. /******/ var installedModules = {};
  15. /******/
  16. /******/ // The require function
  17. /******/ function __webpack_require__(moduleId) {
  18. /******/
  19. /******/ // Check if module is in cache
  20. /******/ if(installedModules[moduleId])
  21. /******/ return installedModules[moduleId].exports;
  22. /******/
  23. /******/ // Create a new module (and put it into the cache)
  24. /******/ var module = installedModules[moduleId] = {
  25. /******/ exports: {},
  26. /******/ id: moduleId,
  27. /******/ loaded: false
  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.loaded = 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. /******/ // __webpack_public_path__
  48. /******/ __webpack_require__.p = "";
  49. /******/
  50. /******/ // Load entry module and return exports
  51. /******/ return __webpack_require__(0);
  52. /******/ })
  53. /************************************************************************/
  54. /******/ ([
  55. /* 0 */
  56. /***/ (function(module, exports, __webpack_require__) {
  57. module.exports = __webpack_require__(1);
  58. /***/ }),
  59. /* 1 */
  60. /***/ (function(module, exports, __webpack_require__) {
  61. 'use strict';
  62. var utils = __webpack_require__(2);
  63. var bind = __webpack_require__(3);
  64. var Axios = __webpack_require__(4);
  65. var mergeConfig = __webpack_require__(22);
  66. var defaults = __webpack_require__(10);
  67. /**
  68. * Create an instance of Axios
  69. *
  70. * @param {Object} defaultConfig The default config for the instance
  71. * @return {Axios} A new instance of Axios
  72. */
  73. function createInstance(defaultConfig) {
  74. var context = new Axios(defaultConfig);
  75. var instance = bind(Axios.prototype.request, context);
  76. // Copy axios.prototype to instance
  77. utils.extend(instance, Axios.prototype, context);
  78. // Copy context to instance
  79. utils.extend(instance, context);
  80. return instance;
  81. }
  82. // Create the default instance to be exported
  83. var axios = createInstance(defaults);
  84. // Expose Axios class to allow class inheritance
  85. axios.Axios = Axios;
  86. // Factory for creating new instances
  87. axios.create = function create(instanceConfig) {
  88. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  89. };
  90. // Expose Cancel & CancelToken
  91. axios.Cancel = __webpack_require__(23);
  92. axios.CancelToken = __webpack_require__(24);
  93. axios.isCancel = __webpack_require__(9);
  94. // Expose all/spread
  95. axios.all = function all(promises) {
  96. return Promise.all(promises);
  97. };
  98. axios.spread = __webpack_require__(25);
  99. module.exports = axios;
  100. // Allow use of default import syntax in TypeScript
  101. module.exports.default = axios;
  102. /***/ }),
  103. /* 2 */
  104. /***/ (function(module, exports, __webpack_require__) {
  105. 'use strict';
  106. var bind = __webpack_require__(3);
  107. /*global toString:true*/
  108. // utils is a library of generic helper functions non-specific to axios
  109. var toString = Object.prototype.toString;
  110. /**
  111. * Determine if a value is an Array
  112. *
  113. * @param {Object} val The value to test
  114. * @returns {boolean} True if value is an Array, otherwise false
  115. */
  116. function isArray(val) {
  117. return toString.call(val) === '[object Array]';
  118. }
  119. /**
  120. * Determine if a value is undefined
  121. *
  122. * @param {Object} val The value to test
  123. * @returns {boolean} True if the value is undefined, otherwise false
  124. */
  125. function isUndefined(val) {
  126. return typeof val === 'undefined';
  127. }
  128. /**
  129. * Determine if a value is a Buffer
  130. *
  131. * @param {Object} val The value to test
  132. * @returns {boolean} True if value is a Buffer, otherwise false
  133. */
  134. function isBuffer(val) {
  135. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  136. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  137. }
  138. /**
  139. * Determine if a value is an ArrayBuffer
  140. *
  141. * @param {Object} val The value to test
  142. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  143. */
  144. function isArrayBuffer(val) {
  145. return toString.call(val) === '[object ArrayBuffer]';
  146. }
  147. /**
  148. * Determine if a value is a FormData
  149. *
  150. * @param {Object} val The value to test
  151. * @returns {boolean} True if value is an FormData, otherwise false
  152. */
  153. function isFormData(val) {
  154. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  155. }
  156. /**
  157. * Determine if a value is a view on an ArrayBuffer
  158. *
  159. * @param {Object} val The value to test
  160. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  161. */
  162. function isArrayBufferView(val) {
  163. var result;
  164. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  165. result = ArrayBuffer.isView(val);
  166. } else {
  167. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  168. }
  169. return result;
  170. }
  171. /**
  172. * Determine if a value is a String
  173. *
  174. * @param {Object} val The value to test
  175. * @returns {boolean} True if value is a String, otherwise false
  176. */
  177. function isString(val) {
  178. return typeof val === 'string';
  179. }
  180. /**
  181. * Determine if a value is a Number
  182. *
  183. * @param {Object} val The value to test
  184. * @returns {boolean} True if value is a Number, otherwise false
  185. */
  186. function isNumber(val) {
  187. return typeof val === 'number';
  188. }
  189. /**
  190. * Determine if a value is an Object
  191. *
  192. * @param {Object} val The value to test
  193. * @returns {boolean} True if value is an Object, otherwise false
  194. */
  195. function isObject(val) {
  196. return val !== null && typeof val === 'object';
  197. }
  198. /**
  199. * Determine if a value is a Date
  200. *
  201. * @param {Object} val The value to test
  202. * @returns {boolean} True if value is a Date, otherwise false
  203. */
  204. function isDate(val) {
  205. return toString.call(val) === '[object Date]';
  206. }
  207. /**
  208. * Determine if a value is a File
  209. *
  210. * @param {Object} val The value to test
  211. * @returns {boolean} True if value is a File, otherwise false
  212. */
  213. function isFile(val) {
  214. return toString.call(val) === '[object File]';
  215. }
  216. /**
  217. * Determine if a value is a Blob
  218. *
  219. * @param {Object} val The value to test
  220. * @returns {boolean} True if value is a Blob, otherwise false
  221. */
  222. function isBlob(val) {
  223. return toString.call(val) === '[object Blob]';
  224. }
  225. /**
  226. * Determine if a value is a Function
  227. *
  228. * @param {Object} val The value to test
  229. * @returns {boolean} True if value is a Function, otherwise false
  230. */
  231. function isFunction(val) {
  232. return toString.call(val) === '[object Function]';
  233. }
  234. /**
  235. * Determine if a value is a Stream
  236. *
  237. * @param {Object} val The value to test
  238. * @returns {boolean} True if value is a Stream, otherwise false
  239. */
  240. function isStream(val) {
  241. return isObject(val) && isFunction(val.pipe);
  242. }
  243. /**
  244. * Determine if a value is a URLSearchParams object
  245. *
  246. * @param {Object} val The value to test
  247. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  248. */
  249. function isURLSearchParams(val) {
  250. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  251. }
  252. /**
  253. * Trim excess whitespace off the beginning and end of a string
  254. *
  255. * @param {String} str The String to trim
  256. * @returns {String} The String freed of excess whitespace
  257. */
  258. function trim(str) {
  259. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  260. }
  261. /**
  262. * Determine if we're running in a standard browser environment
  263. *
  264. * This allows axios to run in a web worker, and react-native.
  265. * Both environments support XMLHttpRequest, but not fully standard globals.
  266. *
  267. * web workers:
  268. * typeof window -> undefined
  269. * typeof document -> undefined
  270. *
  271. * react-native:
  272. * navigator.product -> 'ReactNative'
  273. * nativescript
  274. * navigator.product -> 'NativeScript' or 'NS'
  275. */
  276. function isStandardBrowserEnv() {
  277. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  278. navigator.product === 'NativeScript' ||
  279. navigator.product === 'NS')) {
  280. return false;
  281. }
  282. return (
  283. typeof window !== 'undefined' &&
  284. typeof document !== 'undefined'
  285. );
  286. }
  287. /**
  288. * Iterate over an Array or an Object invoking a function for each item.
  289. *
  290. * If `obj` is an Array callback will be called passing
  291. * the value, index, and complete array for each item.
  292. *
  293. * If 'obj' is an Object callback will be called passing
  294. * the value, key, and complete object for each property.
  295. *
  296. * @param {Object|Array} obj The object to iterate
  297. * @param {Function} fn The callback to invoke for each item
  298. */
  299. function forEach(obj, fn) {
  300. // Don't bother if no value provided
  301. if (obj === null || typeof obj === 'undefined') {
  302. return;
  303. }
  304. // Force an array if not already something iterable
  305. if (typeof obj !== 'object') {
  306. /*eslint no-param-reassign:0*/
  307. obj = [obj];
  308. }
  309. if (isArray(obj)) {
  310. // Iterate over array values
  311. for (var i = 0, l = obj.length; i < l; i++) {
  312. fn.call(null, obj[i], i, obj);
  313. }
  314. } else {
  315. // Iterate over object keys
  316. for (var key in obj) {
  317. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  318. fn.call(null, obj[key], key, obj);
  319. }
  320. }
  321. }
  322. }
  323. /**
  324. * Accepts varargs expecting each argument to be an object, then
  325. * immutably merges the properties of each object and returns result.
  326. *
  327. * When multiple objects contain the same key the later object in
  328. * the arguments list will take precedence.
  329. *
  330. * Example:
  331. *
  332. * ```js
  333. * var result = merge({foo: 123}, {foo: 456});
  334. * console.log(result.foo); // outputs 456
  335. * ```
  336. *
  337. * @param {Object} obj1 Object to merge
  338. * @returns {Object} Result of all merge properties
  339. */
  340. function merge(/* obj1, obj2, obj3, ... */) {
  341. var result = {};
  342. function assignValue(val, key) {
  343. if (typeof result[key] === 'object' && typeof val === 'object') {
  344. result[key] = merge(result[key], val);
  345. } else {
  346. result[key] = val;
  347. }
  348. }
  349. for (var i = 0, l = arguments.length; i < l; i++) {
  350. forEach(arguments[i], assignValue);
  351. }
  352. return result;
  353. }
  354. /**
  355. * Function equal to merge with the difference being that no reference
  356. * to original objects is kept.
  357. *
  358. * @see merge
  359. * @param {Object} obj1 Object to merge
  360. * @returns {Object} Result of all merge properties
  361. */
  362. function deepMerge(/* obj1, obj2, obj3, ... */) {
  363. var result = {};
  364. function assignValue(val, key) {
  365. if (typeof result[key] === 'object' && typeof val === 'object') {
  366. result[key] = deepMerge(result[key], val);
  367. } else if (typeof val === 'object') {
  368. result[key] = deepMerge({}, val);
  369. } else {
  370. result[key] = val;
  371. }
  372. }
  373. for (var i = 0, l = arguments.length; i < l; i++) {
  374. forEach(arguments[i], assignValue);
  375. }
  376. return result;
  377. }
  378. /**
  379. * Extends object a by mutably adding to it the properties of object b.
  380. *
  381. * @param {Object} a The object to be extended
  382. * @param {Object} b The object to copy properties from
  383. * @param {Object} thisArg The object to bind function to
  384. * @return {Object} The resulting value of object a
  385. */
  386. function extend(a, b, thisArg) {
  387. forEach(b, function assignValue(val, key) {
  388. if (thisArg && typeof val === 'function') {
  389. a[key] = bind(val, thisArg);
  390. } else {
  391. a[key] = val;
  392. }
  393. });
  394. return a;
  395. }
  396. module.exports = {
  397. isArray: isArray,
  398. isArrayBuffer: isArrayBuffer,
  399. isBuffer: isBuffer,
  400. isFormData: isFormData,
  401. isArrayBufferView: isArrayBufferView,
  402. isString: isString,
  403. isNumber: isNumber,
  404. isObject: isObject,
  405. isUndefined: isUndefined,
  406. isDate: isDate,
  407. isFile: isFile,
  408. isBlob: isBlob,
  409. isFunction: isFunction,
  410. isStream: isStream,
  411. isURLSearchParams: isURLSearchParams,
  412. isStandardBrowserEnv: isStandardBrowserEnv,
  413. forEach: forEach,
  414. merge: merge,
  415. deepMerge: deepMerge,
  416. extend: extend,
  417. trim: trim
  418. };
  419. /***/ }),
  420. /* 3 */
  421. /***/ (function(module, exports) {
  422. 'use strict';
  423. module.exports = function bind(fn, thisArg) {
  424. return function wrap() {
  425. var args = new Array(arguments.length);
  426. for (var i = 0; i < args.length; i++) {
  427. args[i] = arguments[i];
  428. }
  429. return fn.apply(thisArg, args);
  430. };
  431. };
  432. /***/ }),
  433. /* 4 */
  434. /***/ (function(module, exports, __webpack_require__) {
  435. 'use strict';
  436. var utils = __webpack_require__(2);
  437. var buildURL = __webpack_require__(5);
  438. var InterceptorManager = __webpack_require__(6);
  439. var dispatchRequest = __webpack_require__(7);
  440. var mergeConfig = __webpack_require__(22);
  441. /**
  442. * Create a new instance of Axios
  443. *
  444. * @param {Object} instanceConfig The default config for the instance
  445. */
  446. function Axios(instanceConfig) {
  447. this.defaults = instanceConfig;
  448. this.interceptors = {
  449. request: new InterceptorManager(),
  450. response: new InterceptorManager()
  451. };
  452. }
  453. /**
  454. * Dispatch a request
  455. *
  456. * @param {Object} config The config specific for this request (merged with this.defaults)
  457. */
  458. Axios.prototype.request = function request(config) {
  459. /*eslint no-param-reassign:0*/
  460. // Allow for axios('example/url'[, config]) a la fetch API
  461. if (typeof config === 'string') {
  462. config = arguments[1] || {};
  463. config.url = arguments[0];
  464. } else {
  465. config = config || {};
  466. }
  467. config = mergeConfig(this.defaults, config);
  468. // Set config.method
  469. if (config.method) {
  470. config.method = config.method.toLowerCase();
  471. } else if (this.defaults.method) {
  472. config.method = this.defaults.method.toLowerCase();
  473. } else {
  474. config.method = 'get';
  475. }
  476. // Hook up interceptors middleware
  477. var chain = [dispatchRequest, undefined];
  478. var promise = Promise.resolve(config);
  479. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  480. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  481. });
  482. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  483. chain.push(interceptor.fulfilled, interceptor.rejected);
  484. });
  485. while (chain.length) {
  486. promise = promise.then(chain.shift(), chain.shift());
  487. }
  488. return promise;
  489. };
  490. Axios.prototype.getUri = function getUri(config) {
  491. config = mergeConfig(this.defaults, config);
  492. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  493. };
  494. // Provide aliases for supported request methods
  495. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  496. /*eslint func-names:0*/
  497. Axios.prototype[method] = function(url, config) {
  498. return this.request(utils.merge(config || {}, {
  499. method: method,
  500. url: url
  501. }));
  502. };
  503. });
  504. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  505. /*eslint func-names:0*/
  506. Axios.prototype[method] = function(url, data, config) {
  507. return this.request(utils.merge(config || {}, {
  508. method: method,
  509. url: url,
  510. data: data
  511. }));
  512. };
  513. });
  514. module.exports = Axios;
  515. /***/ }),
  516. /* 5 */
  517. /***/ (function(module, exports, __webpack_require__) {
  518. 'use strict';
  519. var utils = __webpack_require__(2);
  520. function encode(val) {
  521. return encodeURIComponent(val).
  522. replace(/%40/gi, '@').
  523. replace(/%3A/gi, ':').
  524. replace(/%24/g, '$').
  525. replace(/%2C/gi, ',').
  526. replace(/%20/g, '+').
  527. replace(/%5B/gi, '[').
  528. replace(/%5D/gi, ']');
  529. }
  530. /**
  531. * Build a URL by appending params to the end
  532. *
  533. * @param {string} url The base of the url (e.g., http://www.google.com)
  534. * @param {object} [params] The params to be appended
  535. * @returns {string} The formatted url
  536. */
  537. module.exports = function buildURL(url, params, paramsSerializer) {
  538. /*eslint no-param-reassign:0*/
  539. if (!params) {
  540. return url;
  541. }
  542. var serializedParams;
  543. if (paramsSerializer) {
  544. serializedParams = paramsSerializer(params);
  545. } else if (utils.isURLSearchParams(params)) {
  546. serializedParams = params.toString();
  547. } else {
  548. var parts = [];
  549. utils.forEach(params, function serialize(val, key) {
  550. if (val === null || typeof val === 'undefined') {
  551. return;
  552. }
  553. if (utils.isArray(val)) {
  554. key = key + '[]';
  555. } else {
  556. val = [val];
  557. }
  558. utils.forEach(val, function parseValue(v) {
  559. if (utils.isDate(v)) {
  560. v = v.toISOString();
  561. } else if (utils.isObject(v)) {
  562. v = JSON.stringify(v);
  563. }
  564. parts.push(encode(key) + '=' + encode(v));
  565. });
  566. });
  567. serializedParams = parts.join('&');
  568. }
  569. if (serializedParams) {
  570. var hashmarkIndex = url.indexOf('#');
  571. if (hashmarkIndex !== -1) {
  572. url = url.slice(0, hashmarkIndex);
  573. }
  574. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  575. }
  576. return url;
  577. };
  578. /***/ }),
  579. /* 6 */
  580. /***/ (function(module, exports, __webpack_require__) {
  581. 'use strict';
  582. var utils = __webpack_require__(2);
  583. function InterceptorManager() {
  584. this.handlers = [];
  585. }
  586. /**
  587. * Add a new interceptor to the stack
  588. *
  589. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  590. * @param {Function} rejected The function to handle `reject` for a `Promise`
  591. *
  592. * @return {Number} An ID used to remove interceptor later
  593. */
  594. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  595. this.handlers.push({
  596. fulfilled: fulfilled,
  597. rejected: rejected
  598. });
  599. return this.handlers.length - 1;
  600. };
  601. /**
  602. * Remove an interceptor from the stack
  603. *
  604. * @param {Number} id The ID that was returned by `use`
  605. */
  606. InterceptorManager.prototype.eject = function eject(id) {
  607. if (this.handlers[id]) {
  608. this.handlers[id] = null;
  609. }
  610. };
  611. /**
  612. * Iterate over all the registered interceptors
  613. *
  614. * This method is particularly useful for skipping over any
  615. * interceptors that may have become `null` calling `eject`.
  616. *
  617. * @param {Function} fn The function to call for each interceptor
  618. */
  619. InterceptorManager.prototype.forEach = function forEach(fn) {
  620. utils.forEach(this.handlers, function forEachHandler(h) {
  621. if (h !== null) {
  622. fn(h);
  623. }
  624. });
  625. };
  626. module.exports = InterceptorManager;
  627. /***/ }),
  628. /* 7 */
  629. /***/ (function(module, exports, __webpack_require__) {
  630. 'use strict';
  631. var utils = __webpack_require__(2);
  632. var transformData = __webpack_require__(8);
  633. var isCancel = __webpack_require__(9);
  634. var defaults = __webpack_require__(10);
  635. /**
  636. * Throws a `Cancel` if cancellation has been requested.
  637. */
  638. function throwIfCancellationRequested(config) {
  639. if (config.cancelToken) {
  640. config.cancelToken.throwIfRequested();
  641. }
  642. }
  643. /**
  644. * Dispatch a request to the server using the configured adapter.
  645. *
  646. * @param {object} config The config that is to be used for the request
  647. * @returns {Promise} The Promise to be fulfilled
  648. */
  649. module.exports = function dispatchRequest(config) {
  650. throwIfCancellationRequested(config);
  651. // Ensure headers exist
  652. config.headers = config.headers || {};
  653. // Transform request data
  654. config.data = transformData(
  655. config.data,
  656. config.headers,
  657. config.transformRequest
  658. );
  659. // Flatten headers
  660. config.headers = utils.merge(
  661. config.headers.common || {},
  662. config.headers[config.method] || {},
  663. config.headers
  664. );
  665. utils.forEach(
  666. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  667. function cleanHeaderConfig(method) {
  668. delete config.headers[method];
  669. }
  670. );
  671. var adapter = config.adapter || defaults.adapter;
  672. return adapter(config).then(function onAdapterResolution(response) {
  673. throwIfCancellationRequested(config);
  674. // Transform response data
  675. response.data = transformData(
  676. response.data,
  677. response.headers,
  678. config.transformResponse
  679. );
  680. return response;
  681. }, function onAdapterRejection(reason) {
  682. if (!isCancel(reason)) {
  683. throwIfCancellationRequested(config);
  684. // Transform response data
  685. if (reason && reason.response) {
  686. reason.response.data = transformData(
  687. reason.response.data,
  688. reason.response.headers,
  689. config.transformResponse
  690. );
  691. }
  692. }
  693. return Promise.reject(reason);
  694. });
  695. };
  696. /***/ }),
  697. /* 8 */
  698. /***/ (function(module, exports, __webpack_require__) {
  699. 'use strict';
  700. var utils = __webpack_require__(2);
  701. /**
  702. * Transform the data for a request or a response
  703. *
  704. * @param {Object|String} data The data to be transformed
  705. * @param {Array} headers The headers for the request or response
  706. * @param {Array|Function} fns A single function or Array of functions
  707. * @returns {*} The resulting transformed data
  708. */
  709. module.exports = function transformData(data, headers, fns) {
  710. /*eslint no-param-reassign:0*/
  711. utils.forEach(fns, function transform(fn) {
  712. data = fn(data, headers);
  713. });
  714. return data;
  715. };
  716. /***/ }),
  717. /* 9 */
  718. /***/ (function(module, exports) {
  719. 'use strict';
  720. module.exports = function isCancel(value) {
  721. return !!(value && value.__CANCEL__);
  722. };
  723. /***/ }),
  724. /* 10 */
  725. /***/ (function(module, exports, __webpack_require__) {
  726. 'use strict';
  727. var utils = __webpack_require__(2);
  728. var normalizeHeaderName = __webpack_require__(11);
  729. var DEFAULT_CONTENT_TYPE = {
  730. 'Content-Type': 'application/x-www-form-urlencoded'
  731. };
  732. function setContentTypeIfUnset(headers, value) {
  733. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  734. headers['Content-Type'] = value;
  735. }
  736. }
  737. function getDefaultAdapter() {
  738. var adapter;
  739. if (typeof XMLHttpRequest !== 'undefined') {
  740. // For browsers use XHR adapter
  741. adapter = __webpack_require__(12);
  742. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  743. // For node use HTTP adapter
  744. adapter = __webpack_require__(12);
  745. }
  746. return adapter;
  747. }
  748. var defaults = {
  749. adapter: getDefaultAdapter(),
  750. transformRequest: [function transformRequest(data, headers) {
  751. normalizeHeaderName(headers, 'Accept');
  752. normalizeHeaderName(headers, 'Content-Type');
  753. if (utils.isFormData(data) ||
  754. utils.isArrayBuffer(data) ||
  755. utils.isBuffer(data) ||
  756. utils.isStream(data) ||
  757. utils.isFile(data) ||
  758. utils.isBlob(data)
  759. ) {
  760. return data;
  761. }
  762. if (utils.isArrayBufferView(data)) {
  763. return data.buffer;
  764. }
  765. if (utils.isURLSearchParams(data)) {
  766. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  767. return data.toString();
  768. }
  769. if (utils.isObject(data)) {
  770. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  771. return JSON.stringify(data);
  772. }
  773. return data;
  774. }],
  775. transformResponse: [function transformResponse(data) {
  776. /*eslint no-param-reassign:0*/
  777. if (typeof data === 'string') {
  778. try {
  779. data = JSON.parse(data);
  780. } catch (e) { /* Ignore */ }
  781. }
  782. return data;
  783. }],
  784. /**
  785. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  786. * timeout is not created.
  787. */
  788. timeout: 0,
  789. xsrfCookieName: 'XSRF-TOKEN',
  790. xsrfHeaderName: 'X-XSRF-TOKEN',
  791. maxContentLength: -1,
  792. validateStatus: function validateStatus(status) {
  793. return status >= 200 && status < 300;
  794. }
  795. };
  796. defaults.headers = {
  797. common: {
  798. 'Accept': 'application/json, text/plain, */*'
  799. }
  800. };
  801. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  802. defaults.headers[method] = {};
  803. });
  804. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  805. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  806. });
  807. module.exports = defaults;
  808. /***/ }),
  809. /* 11 */
  810. /***/ (function(module, exports, __webpack_require__) {
  811. 'use strict';
  812. var utils = __webpack_require__(2);
  813. module.exports = function normalizeHeaderName(headers, normalizedName) {
  814. utils.forEach(headers, function processHeader(value, name) {
  815. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  816. headers[normalizedName] = value;
  817. delete headers[name];
  818. }
  819. });
  820. };
  821. /***/ }),
  822. /* 12 */
  823. /***/ (function(module, exports, __webpack_require__) {
  824. 'use strict';
  825. var utils = __webpack_require__(2);
  826. var settle = __webpack_require__(13);
  827. var buildURL = __webpack_require__(5);
  828. var buildFullPath = __webpack_require__(16);
  829. var parseHeaders = __webpack_require__(19);
  830. var isURLSameOrigin = __webpack_require__(20);
  831. var createError = __webpack_require__(14);
  832. module.exports = function xhrAdapter(config) {
  833. return new Promise(function dispatchXhrRequest(resolve, reject) {
  834. var requestData = config.data;
  835. var requestHeaders = config.headers;
  836. if (utils.isFormData(requestData)) {
  837. delete requestHeaders['Content-Type']; // Let the browser set it
  838. }
  839. var request = new XMLHttpRequest();
  840. // HTTP basic authentication
  841. if (config.auth) {
  842. var username = config.auth.username || '';
  843. var password = config.auth.password || '';
  844. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  845. }
  846. var fullPath = buildFullPath(config.baseURL, config.url);
  847. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  848. // Set the request timeout in MS
  849. request.timeout = config.timeout;
  850. // Listen for ready state
  851. request.onreadystatechange = function handleLoad() {
  852. if (!request || request.readyState !== 4) {
  853. return;
  854. }
  855. // The request errored out and we didn't get a response, this will be
  856. // handled by onerror instead
  857. // With one exception: request that using file: protocol, most browsers
  858. // will return status as 0 even though it's a successful request
  859. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  860. return;
  861. }
  862. // Prepare the response
  863. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  864. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  865. var response = {
  866. data: responseData,
  867. status: request.status,
  868. statusText: request.statusText,
  869. headers: responseHeaders,
  870. config: config,
  871. request: request
  872. };
  873. settle(resolve, reject, response);
  874. // Clean up request
  875. request = null;
  876. };
  877. // Handle browser request cancellation (as opposed to a manual cancellation)
  878. request.onabort = function handleAbort() {
  879. if (!request) {
  880. return;
  881. }
  882. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  883. // Clean up request
  884. request = null;
  885. };
  886. // Handle low level network errors
  887. request.onerror = function handleError() {
  888. // Real errors are hidden from us by the browser
  889. // onerror should only fire if it's a network error
  890. reject(createError('Network Error', config, null, request));
  891. // Clean up request
  892. request = null;
  893. };
  894. // Handle timeout
  895. request.ontimeout = function handleTimeout() {
  896. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  897. if (config.timeoutErrorMessage) {
  898. timeoutErrorMessage = config.timeoutErrorMessage;
  899. }
  900. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  901. request));
  902. // Clean up request
  903. request = null;
  904. };
  905. // Add xsrf header
  906. // This is only done if running in a standard browser environment.
  907. // Specifically not if we're in a web worker, or react-native.
  908. if (utils.isStandardBrowserEnv()) {
  909. var cookies = __webpack_require__(21);
  910. // Add xsrf header
  911. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  912. cookies.read(config.xsrfCookieName) :
  913. undefined;
  914. if (xsrfValue) {
  915. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  916. }
  917. }
  918. // Add headers to the request
  919. if ('setRequestHeader' in request) {
  920. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  921. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  922. // Remove Content-Type if data is undefined
  923. delete requestHeaders[key];
  924. } else {
  925. // Otherwise add header to the request
  926. request.setRequestHeader(key, val);
  927. }
  928. });
  929. }
  930. // Add withCredentials to request if needed
  931. if (!utils.isUndefined(config.withCredentials)) {
  932. request.withCredentials = !!config.withCredentials;
  933. }
  934. // Add responseType to request if needed
  935. if (config.responseType) {
  936. try {
  937. request.responseType = config.responseType;
  938. } catch (e) {
  939. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  940. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  941. if (config.responseType !== 'json') {
  942. throw e;
  943. }
  944. }
  945. }
  946. // Handle progress if needed
  947. if (typeof config.onDownloadProgress === 'function') {
  948. request.addEventListener('progress', config.onDownloadProgress);
  949. }
  950. // Not all browsers support upload events
  951. if (typeof config.onUploadProgress === 'function' && request.upload) {
  952. request.upload.addEventListener('progress', config.onUploadProgress);
  953. }
  954. if (config.cancelToken) {
  955. // Handle cancellation
  956. config.cancelToken.promise.then(function onCanceled(cancel) {
  957. if (!request) {
  958. return;
  959. }
  960. request.abort();
  961. reject(cancel);
  962. // Clean up request
  963. request = null;
  964. });
  965. }
  966. if (requestData === undefined) {
  967. requestData = null;
  968. }
  969. // Send the request
  970. request.send(requestData);
  971. });
  972. };
  973. /***/ }),
  974. /* 13 */
  975. /***/ (function(module, exports, __webpack_require__) {
  976. 'use strict';
  977. var createError = __webpack_require__(14);
  978. /**
  979. * Resolve or reject a Promise based on response status.
  980. *
  981. * @param {Function} resolve A function that resolves the promise.
  982. * @param {Function} reject A function that rejects the promise.
  983. * @param {object} response The response.
  984. */
  985. module.exports = function settle(resolve, reject, response) {
  986. var validateStatus = response.config.validateStatus;
  987. if (!validateStatus || validateStatus(response.status)) {
  988. resolve(response);
  989. } else {
  990. reject(createError(
  991. 'Request failed with status code ' + response.status,
  992. response.config,
  993. null,
  994. response.request,
  995. response
  996. ));
  997. }
  998. };
  999. /***/ }),
  1000. /* 14 */
  1001. /***/ (function(module, exports, __webpack_require__) {
  1002. 'use strict';
  1003. var enhanceError = __webpack_require__(15);
  1004. /**
  1005. * Create an Error with the specified message, config, error code, request and response.
  1006. *
  1007. * @param {string} message The error message.
  1008. * @param {Object} config The config.
  1009. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1010. * @param {Object} [request] The request.
  1011. * @param {Object} [response] The response.
  1012. * @returns {Error} The created error.
  1013. */
  1014. module.exports = function createError(message, config, code, request, response) {
  1015. var error = new Error(message);
  1016. return enhanceError(error, config, code, request, response);
  1017. };
  1018. /***/ }),
  1019. /* 15 */
  1020. /***/ (function(module, exports) {
  1021. 'use strict';
  1022. /**
  1023. * Update an Error with the specified config, error code, and response.
  1024. *
  1025. * @param {Error} error The error to update.
  1026. * @param {Object} config The config.
  1027. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1028. * @param {Object} [request] The request.
  1029. * @param {Object} [response] The response.
  1030. * @returns {Error} The error.
  1031. */
  1032. module.exports = function enhanceError(error, config, code, request, response) {
  1033. error.config = config;
  1034. if (code) {
  1035. error.code = code;
  1036. }
  1037. error.request = request;
  1038. error.response = response;
  1039. error.isAxiosError = true;
  1040. error.toJSON = function() {
  1041. return {
  1042. // Standard
  1043. message: this.message,
  1044. name: this.name,
  1045. // Microsoft
  1046. description: this.description,
  1047. number: this.number,
  1048. // Mozilla
  1049. fileName: this.fileName,
  1050. lineNumber: this.lineNumber,
  1051. columnNumber: this.columnNumber,
  1052. stack: this.stack,
  1053. // Axios
  1054. config: this.config,
  1055. code: this.code
  1056. };
  1057. };
  1058. return error;
  1059. };
  1060. /***/ }),
  1061. /* 16 */
  1062. /***/ (function(module, exports, __webpack_require__) {
  1063. 'use strict';
  1064. var isAbsoluteURL = __webpack_require__(17);
  1065. var combineURLs = __webpack_require__(18);
  1066. /**
  1067. * Creates a new URL by combining the baseURL with the requestedURL,
  1068. * only when the requestedURL is not already an absolute URL.
  1069. * If the requestURL is absolute, this function returns the requestedURL untouched.
  1070. *
  1071. * @param {string} baseURL The base URL
  1072. * @param {string} requestedURL Absolute or relative URL to combine
  1073. * @returns {string} The combined full path
  1074. */
  1075. module.exports = function buildFullPath(baseURL, requestedURL) {
  1076. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1077. return combineURLs(baseURL, requestedURL);
  1078. }
  1079. return requestedURL;
  1080. };
  1081. /***/ }),
  1082. /* 17 */
  1083. /***/ (function(module, exports) {
  1084. 'use strict';
  1085. /**
  1086. * Determines whether the specified URL is absolute
  1087. *
  1088. * @param {string} url The URL to test
  1089. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1090. */
  1091. module.exports = function isAbsoluteURL(url) {
  1092. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1093. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1094. // by any combination of letters, digits, plus, period, or hyphen.
  1095. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1096. };
  1097. /***/ }),
  1098. /* 18 */
  1099. /***/ (function(module, exports) {
  1100. 'use strict';
  1101. /**
  1102. * Creates a new URL by combining the specified URLs
  1103. *
  1104. * @param {string} baseURL The base URL
  1105. * @param {string} relativeURL The relative URL
  1106. * @returns {string} The combined URL
  1107. */
  1108. module.exports = function combineURLs(baseURL, relativeURL) {
  1109. return relativeURL
  1110. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1111. : baseURL;
  1112. };
  1113. /***/ }),
  1114. /* 19 */
  1115. /***/ (function(module, exports, __webpack_require__) {
  1116. 'use strict';
  1117. var utils = __webpack_require__(2);
  1118. // Headers whose duplicates are ignored by node
  1119. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1120. var ignoreDuplicateOf = [
  1121. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1122. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1123. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1124. 'referer', 'retry-after', 'user-agent'
  1125. ];
  1126. /**
  1127. * Parse headers into an object
  1128. *
  1129. * ```
  1130. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1131. * Content-Type: application/json
  1132. * Connection: keep-alive
  1133. * Transfer-Encoding: chunked
  1134. * ```
  1135. *
  1136. * @param {String} headers Headers needing to be parsed
  1137. * @returns {Object} Headers parsed into an object
  1138. */
  1139. module.exports = function parseHeaders(headers) {
  1140. var parsed = {};
  1141. var key;
  1142. var val;
  1143. var i;
  1144. if (!headers) { return parsed; }
  1145. utils.forEach(headers.split('\n'), function parser(line) {
  1146. i = line.indexOf(':');
  1147. key = utils.trim(line.substr(0, i)).toLowerCase();
  1148. val = utils.trim(line.substr(i + 1));
  1149. if (key) {
  1150. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1151. return;
  1152. }
  1153. if (key === 'set-cookie') {
  1154. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1155. } else {
  1156. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1157. }
  1158. }
  1159. });
  1160. return parsed;
  1161. };
  1162. /***/ }),
  1163. /* 20 */
  1164. /***/ (function(module, exports, __webpack_require__) {
  1165. 'use strict';
  1166. var utils = __webpack_require__(2);
  1167. module.exports = (
  1168. utils.isStandardBrowserEnv() ?
  1169. // Standard browser envs have full support of the APIs needed to test
  1170. // whether the request URL is of the same origin as current location.
  1171. (function standardBrowserEnv() {
  1172. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1173. var urlParsingNode = document.createElement('a');
  1174. var originURL;
  1175. /**
  1176. * Parse a URL to discover it's components
  1177. *
  1178. * @param {String} url The URL to be parsed
  1179. * @returns {Object}
  1180. */
  1181. function resolveURL(url) {
  1182. var href = url;
  1183. if (msie) {
  1184. // IE needs attribute set twice to normalize properties
  1185. urlParsingNode.setAttribute('href', href);
  1186. href = urlParsingNode.href;
  1187. }
  1188. urlParsingNode.setAttribute('href', href);
  1189. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1190. return {
  1191. href: urlParsingNode.href,
  1192. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1193. host: urlParsingNode.host,
  1194. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1195. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1196. hostname: urlParsingNode.hostname,
  1197. port: urlParsingNode.port,
  1198. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1199. urlParsingNode.pathname :
  1200. '/' + urlParsingNode.pathname
  1201. };
  1202. }
  1203. originURL = resolveURL(window.location.href);
  1204. /**
  1205. * Determine if a URL shares the same origin as the current location
  1206. *
  1207. * @param {String} requestURL The URL to test
  1208. * @returns {boolean} True if URL shares the same origin, otherwise false
  1209. */
  1210. return function isURLSameOrigin(requestURL) {
  1211. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1212. return (parsed.protocol === originURL.protocol &&
  1213. parsed.host === originURL.host);
  1214. };
  1215. })() :
  1216. // Non standard browser envs (web workers, react-native) lack needed support.
  1217. (function nonStandardBrowserEnv() {
  1218. return function isURLSameOrigin() {
  1219. return true;
  1220. };
  1221. })()
  1222. );
  1223. /***/ }),
  1224. /* 21 */
  1225. /***/ (function(module, exports, __webpack_require__) {
  1226. 'use strict';
  1227. var utils = __webpack_require__(2);
  1228. module.exports = (
  1229. utils.isStandardBrowserEnv() ?
  1230. // Standard browser envs support document.cookie
  1231. (function standardBrowserEnv() {
  1232. return {
  1233. write: function write(name, value, expires, path, domain, secure) {
  1234. var cookie = [];
  1235. cookie.push(name + '=' + encodeURIComponent(value));
  1236. if (utils.isNumber(expires)) {
  1237. cookie.push('expires=' + new Date(expires).toGMTString());
  1238. }
  1239. if (utils.isString(path)) {
  1240. cookie.push('path=' + path);
  1241. }
  1242. if (utils.isString(domain)) {
  1243. cookie.push('domain=' + domain);
  1244. }
  1245. if (secure === true) {
  1246. cookie.push('secure');
  1247. }
  1248. document.cookie = cookie.join('; ');
  1249. },
  1250. read: function read(name) {
  1251. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1252. return (match ? decodeURIComponent(match[3]) : null);
  1253. },
  1254. remove: function remove(name) {
  1255. this.write(name, '', Date.now() - 86400000);
  1256. }
  1257. };
  1258. })() :
  1259. // Non standard browser env (web workers, react-native) lack needed support.
  1260. (function nonStandardBrowserEnv() {
  1261. return {
  1262. write: function write() {},
  1263. read: function read() { return null; },
  1264. remove: function remove() {}
  1265. };
  1266. })()
  1267. );
  1268. /***/ }),
  1269. /* 22 */
  1270. /***/ (function(module, exports, __webpack_require__) {
  1271. 'use strict';
  1272. var utils = __webpack_require__(2);
  1273. /**
  1274. * Config-specific merge-function which creates a new config-object
  1275. * by merging two configuration objects together.
  1276. *
  1277. * @param {Object} config1
  1278. * @param {Object} config2
  1279. * @returns {Object} New object resulting from merging config2 to config1
  1280. */
  1281. module.exports = function mergeConfig(config1, config2) {
  1282. // eslint-disable-next-line no-param-reassign
  1283. config2 = config2 || {};
  1284. var config = {};
  1285. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  1286. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  1287. var defaultToConfig2Keys = [
  1288. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  1289. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  1290. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  1291. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  1292. 'httpsAgent', 'cancelToken', 'socketPath'
  1293. ];
  1294. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  1295. if (typeof config2[prop] !== 'undefined') {
  1296. config[prop] = config2[prop];
  1297. }
  1298. });
  1299. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  1300. if (utils.isObject(config2[prop])) {
  1301. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  1302. } else if (typeof config2[prop] !== 'undefined') {
  1303. config[prop] = config2[prop];
  1304. } else if (utils.isObject(config1[prop])) {
  1305. config[prop] = utils.deepMerge(config1[prop]);
  1306. } else if (typeof config1[prop] !== 'undefined') {
  1307. config[prop] = config1[prop];
  1308. }
  1309. });
  1310. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  1311. if (typeof config2[prop] !== 'undefined') {
  1312. config[prop] = config2[prop];
  1313. } else if (typeof config1[prop] !== 'undefined') {
  1314. config[prop] = config1[prop];
  1315. }
  1316. });
  1317. var axiosKeys = valueFromConfig2Keys
  1318. .concat(mergeDeepPropertiesKeys)
  1319. .concat(defaultToConfig2Keys);
  1320. var otherKeys = Object
  1321. .keys(config2)
  1322. .filter(function filterAxiosKeys(key) {
  1323. return axiosKeys.indexOf(key) === -1;
  1324. });
  1325. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  1326. if (typeof config2[prop] !== 'undefined') {
  1327. config[prop] = config2[prop];
  1328. } else if (typeof config1[prop] !== 'undefined') {
  1329. config[prop] = config1[prop];
  1330. }
  1331. });
  1332. return config;
  1333. };
  1334. /***/ }),
  1335. /* 23 */
  1336. /***/ (function(module, exports) {
  1337. 'use strict';
  1338. /**
  1339. * A `Cancel` is an object that is thrown when an operation is canceled.
  1340. *
  1341. * @class
  1342. * @param {string=} message The message.
  1343. */
  1344. function Cancel(message) {
  1345. this.message = message;
  1346. }
  1347. Cancel.prototype.toString = function toString() {
  1348. return 'Cancel' + (this.message ? ': ' + this.message : '');
  1349. };
  1350. Cancel.prototype.__CANCEL__ = true;
  1351. module.exports = Cancel;
  1352. /***/ }),
  1353. /* 24 */
  1354. /***/ (function(module, exports, __webpack_require__) {
  1355. 'use strict';
  1356. var Cancel = __webpack_require__(23);
  1357. /**
  1358. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  1359. *
  1360. * @class
  1361. * @param {Function} executor The executor function.
  1362. */
  1363. function CancelToken(executor) {
  1364. if (typeof executor !== 'function') {
  1365. throw new TypeError('executor must be a function.');
  1366. }
  1367. var resolvePromise;
  1368. this.promise = new Promise(function promiseExecutor(resolve) {
  1369. resolvePromise = resolve;
  1370. });
  1371. var token = this;
  1372. executor(function cancel(message) {
  1373. if (token.reason) {
  1374. // Cancellation has already been requested
  1375. return;
  1376. }
  1377. token.reason = new Cancel(message);
  1378. resolvePromise(token.reason);
  1379. });
  1380. }
  1381. /**
  1382. * Throws a `Cancel` if cancellation has been requested.
  1383. */
  1384. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  1385. if (this.reason) {
  1386. throw this.reason;
  1387. }
  1388. };
  1389. /**
  1390. * Returns an object that contains a new `CancelToken` and a function that, when called,
  1391. * cancels the `CancelToken`.
  1392. */
  1393. CancelToken.source = function source() {
  1394. var cancel;
  1395. var token = new CancelToken(function executor(c) {
  1396. cancel = c;
  1397. });
  1398. return {
  1399. token: token,
  1400. cancel: cancel
  1401. };
  1402. };
  1403. module.exports = CancelToken;
  1404. /***/ }),
  1405. /* 25 */
  1406. /***/ (function(module, exports) {
  1407. 'use strict';
  1408. /**
  1409. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1410. *
  1411. * Common use case would be to use `Function.prototype.apply`.
  1412. *
  1413. * ```js
  1414. * function f(x, y, z) {}
  1415. * var args = [1, 2, 3];
  1416. * f.apply(null, args);
  1417. * ```
  1418. *
  1419. * With `spread` this example can be re-written.
  1420. *
  1421. * ```js
  1422. * spread(function(x, y, z) {})([1, 2, 3]);
  1423. * ```
  1424. *
  1425. * @param {Function} callback
  1426. * @returns {Function}
  1427. */
  1428. module.exports = function spread(callback) {
  1429. return function wrap(arr) {
  1430. return callback.apply(null, arr);
  1431. };
  1432. };
  1433. /***/ })
  1434. /******/ ])
  1435. });
  1436. ;
  1437. //# sourceMappingURL=axios.map