axios.js 42 KB

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