axios.js 44 KB

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