axios.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  1. /* axios v0.16.2 | (c) 2017 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' && !isArray(obj)) {
  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 <feross@feross.org> <http://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. var isAbsoluteURL = __webpack_require__(21);
  423. var combineURLs = __webpack_require__(22);
  424. /**
  425. * Create a new instance of Axios
  426. *
  427. * @param {Object} instanceConfig The default config for the instance
  428. */
  429. function Axios(instanceConfig) {
  430. this.defaults = instanceConfig;
  431. this.interceptors = {
  432. request: new InterceptorManager(),
  433. response: new InterceptorManager()
  434. };
  435. }
  436. /**
  437. * Dispatch a request
  438. *
  439. * @param {Object} config The config specific for this request (merged with this.defaults)
  440. */
  441. Axios.prototype.request = function request(config) {
  442. /*eslint no-param-reassign:0*/
  443. // Allow for axios('example/url'[, config]) a la fetch API
  444. if (typeof config === 'string') {
  445. config = utils.merge({
  446. url: arguments[0]
  447. }, arguments[1]);
  448. }
  449. config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
  450. config.method = config.method.toLowerCase();
  451. // Support baseURL config
  452. if (config.baseURL && !isAbsoluteURL(config.url)) {
  453. config.url = combineURLs(config.baseURL, config.url);
  454. }
  455. // Hook up interceptors middleware
  456. var chain = [dispatchRequest, undefined];
  457. var promise = Promise.resolve(config);
  458. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  459. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  460. });
  461. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  462. chain.push(interceptor.fulfilled, interceptor.rejected);
  463. });
  464. while (chain.length) {
  465. promise = promise.then(chain.shift(), chain.shift());
  466. }
  467. return promise;
  468. };
  469. // Provide aliases for supported request methods
  470. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  471. /*eslint func-names:0*/
  472. Axios.prototype[method] = function(url, config) {
  473. return this.request(utils.merge(config || {}, {
  474. method: method,
  475. url: url
  476. }));
  477. };
  478. });
  479. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  480. /*eslint func-names:0*/
  481. Axios.prototype[method] = function(url, data, config) {
  482. return this.request(utils.merge(config || {}, {
  483. method: method,
  484. url: url,
  485. data: data
  486. }));
  487. };
  488. });
  489. module.exports = Axios;
  490. /***/ },
  491. /* 6 */
  492. /***/ function(module, exports, __webpack_require__) {
  493. 'use strict';
  494. var utils = __webpack_require__(2);
  495. var normalizeHeaderName = __webpack_require__(7);
  496. var DEFAULT_CONTENT_TYPE = {
  497. 'Content-Type': 'application/x-www-form-urlencoded'
  498. };
  499. function setContentTypeIfUnset(headers, value) {
  500. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  501. headers['Content-Type'] = value;
  502. }
  503. }
  504. function getDefaultAdapter() {
  505. var adapter;
  506. if (typeof XMLHttpRequest !== 'undefined') {
  507. // For browsers use XHR adapter
  508. adapter = __webpack_require__(8);
  509. } else if (typeof process !== 'undefined') {
  510. // For node use HTTP adapter
  511. adapter = __webpack_require__(8);
  512. }
  513. return adapter;
  514. }
  515. var defaults = {
  516. adapter: getDefaultAdapter(),
  517. transformRequest: [function transformRequest(data, headers) {
  518. normalizeHeaderName(headers, 'Content-Type');
  519. if (utils.isFormData(data) ||
  520. utils.isArrayBuffer(data) ||
  521. utils.isBuffer(data) ||
  522. utils.isStream(data) ||
  523. utils.isFile(data) ||
  524. utils.isBlob(data)
  525. ) {
  526. return data;
  527. }
  528. if (utils.isArrayBufferView(data)) {
  529. return data.buffer;
  530. }
  531. if (utils.isURLSearchParams(data)) {
  532. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  533. return data.toString();
  534. }
  535. if (utils.isObject(data)) {
  536. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  537. return JSON.stringify(data);
  538. }
  539. return data;
  540. }],
  541. transformResponse: [function transformResponse(data) {
  542. /*eslint no-param-reassign:0*/
  543. if (typeof data === 'string') {
  544. try {
  545. data = JSON.parse(data);
  546. } catch (e) { /* Ignore */ }
  547. }
  548. return data;
  549. }],
  550. timeout: 0,
  551. xsrfCookieName: 'XSRF-TOKEN',
  552. xsrfHeaderName: 'X-XSRF-TOKEN',
  553. maxContentLength: -1,
  554. validateStatus: function validateStatus(status) {
  555. return status >= 200 && status < 300;
  556. }
  557. };
  558. defaults.headers = {
  559. common: {
  560. 'Accept': 'application/json, text/plain, */*'
  561. }
  562. };
  563. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  564. defaults.headers[method] = {};
  565. });
  566. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  567. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  568. });
  569. module.exports = defaults;
  570. /***/ },
  571. /* 7 */
  572. /***/ function(module, exports, __webpack_require__) {
  573. 'use strict';
  574. var utils = __webpack_require__(2);
  575. module.exports = function normalizeHeaderName(headers, normalizedName) {
  576. utils.forEach(headers, function processHeader(value, name) {
  577. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  578. headers[normalizedName] = value;
  579. delete headers[name];
  580. }
  581. });
  582. };
  583. /***/ },
  584. /* 8 */
  585. /***/ function(module, exports, __webpack_require__) {
  586. 'use strict';
  587. var utils = __webpack_require__(2);
  588. var settle = __webpack_require__(9);
  589. var buildURL = __webpack_require__(12);
  590. var parseHeaders = __webpack_require__(13);
  591. var isURLSameOrigin = __webpack_require__(14);
  592. var createError = __webpack_require__(10);
  593. var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);
  594. module.exports = function xhrAdapter(config) {
  595. return new Promise(function dispatchXhrRequest(resolve, reject) {
  596. var requestData = config.data;
  597. var requestHeaders = config.headers;
  598. if (utils.isFormData(requestData)) {
  599. delete requestHeaders['Content-Type']; // Let the browser set it
  600. }
  601. var request = new XMLHttpRequest();
  602. var loadEvent = 'onreadystatechange';
  603. var xDomain = false;
  604. // For IE 8/9 CORS support
  605. // Only supports POST and GET calls and doesn't returns the response headers.
  606. // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
  607. if (("production") !== 'test' &&
  608. typeof window !== 'undefined' &&
  609. window.XDomainRequest && !('withCredentials' in request) &&
  610. !isURLSameOrigin(config.url)) {
  611. request = new window.XDomainRequest();
  612. loadEvent = 'onload';
  613. xDomain = true;
  614. request.onprogress = function handleProgress() {};
  615. request.ontimeout = function handleTimeout() {};
  616. }
  617. // HTTP basic authentication
  618. if (config.auth) {
  619. var username = config.auth.username || '';
  620. var password = config.auth.password || '';
  621. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  622. }
  623. request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
  624. // Set the request timeout in MS
  625. request.timeout = config.timeout;
  626. // Listen for ready state
  627. request[loadEvent] = function handleLoad() {
  628. if (!request || (request.readyState !== 4 && !xDomain)) {
  629. return;
  630. }
  631. // The request errored out and we didn't get a response, this will be
  632. // handled by onerror instead
  633. // With one exception: request that using file: protocol, most browsers
  634. // will return status as 0 even though it's a successful request
  635. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  636. return;
  637. }
  638. // Prepare the response
  639. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  640. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  641. var response = {
  642. data: responseData,
  643. // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
  644. status: request.status === 1223 ? 204 : request.status,
  645. statusText: request.status === 1223 ? 'No Content' : request.statusText,
  646. headers: responseHeaders,
  647. config: config,
  648. request: request
  649. };
  650. settle(resolve, reject, response);
  651. // Clean up request
  652. request = null;
  653. };
  654. // Handle low level network errors
  655. request.onerror = function handleError() {
  656. // Real errors are hidden from us by the browser
  657. // onerror should only fire if it's a network error
  658. reject(createError('Network Error', config, null, request));
  659. // Clean up request
  660. request = null;
  661. };
  662. // Handle timeout
  663. request.ontimeout = function handleTimeout() {
  664. reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
  665. request));
  666. // Clean up request
  667. request = null;
  668. };
  669. // Add xsrf header
  670. // This is only done if running in a standard browser environment.
  671. // Specifically not if we're in a web worker, or react-native.
  672. if (utils.isStandardBrowserEnv()) {
  673. var cookies = __webpack_require__(16);
  674. // Add xsrf header
  675. var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
  676. cookies.read(config.xsrfCookieName) :
  677. undefined;
  678. if (xsrfValue) {
  679. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  680. }
  681. }
  682. // Add headers to the request
  683. if ('setRequestHeader' in request) {
  684. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  685. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  686. // Remove Content-Type if data is undefined
  687. delete requestHeaders[key];
  688. } else {
  689. // Otherwise add header to the request
  690. request.setRequestHeader(key, val);
  691. }
  692. });
  693. }
  694. // Add withCredentials to request if needed
  695. if (config.withCredentials) {
  696. request.withCredentials = true;
  697. }
  698. // Add responseType to request if needed
  699. if (config.responseType) {
  700. try {
  701. request.responseType = config.responseType;
  702. } catch (e) {
  703. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  704. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  705. if (config.responseType !== 'json') {
  706. throw e;
  707. }
  708. }
  709. }
  710. // Handle progress if needed
  711. if (typeof config.onDownloadProgress === 'function') {
  712. request.addEventListener('progress', config.onDownloadProgress);
  713. }
  714. // Not all browsers support upload events
  715. if (typeof config.onUploadProgress === 'function' && request.upload) {
  716. request.upload.addEventListener('progress', config.onUploadProgress);
  717. }
  718. if (config.cancelToken) {
  719. // Handle cancellation
  720. config.cancelToken.promise.then(function onCanceled(cancel) {
  721. if (!request) {
  722. return;
  723. }
  724. request.abort();
  725. reject(cancel);
  726. // Clean up request
  727. request = null;
  728. });
  729. }
  730. if (requestData === undefined) {
  731. requestData = null;
  732. }
  733. // Send the request
  734. request.send(requestData);
  735. });
  736. };
  737. /***/ },
  738. /* 9 */
  739. /***/ function(module, exports, __webpack_require__) {
  740. 'use strict';
  741. var createError = __webpack_require__(10);
  742. /**
  743. * Resolve or reject a Promise based on response status.
  744. *
  745. * @param {Function} resolve A function that resolves the promise.
  746. * @param {Function} reject A function that rejects the promise.
  747. * @param {object} response The response.
  748. */
  749. module.exports = function settle(resolve, reject, response) {
  750. var validateStatus = response.config.validateStatus;
  751. // Note: status is not exposed by XDomainRequest
  752. if (!response.status || !validateStatus || validateStatus(response.status)) {
  753. resolve(response);
  754. } else {
  755. reject(createError(
  756. 'Request failed with status code ' + response.status,
  757. response.config,
  758. null,
  759. response.request,
  760. response
  761. ));
  762. }
  763. };
  764. /***/ },
  765. /* 10 */
  766. /***/ function(module, exports, __webpack_require__) {
  767. 'use strict';
  768. var enhanceError = __webpack_require__(11);
  769. /**
  770. * Create an Error with the specified message, config, error code, request and response.
  771. *
  772. * @param {string} message The error message.
  773. * @param {Object} config The config.
  774. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  775. * @param {Object} [request] The request.
  776. * @param {Object} [response] The response.
  777. * @returns {Error} The created error.
  778. */
  779. module.exports = function createError(message, config, code, request, response) {
  780. var error = new Error(message);
  781. return enhanceError(error, config, code, request, response);
  782. };
  783. /***/ },
  784. /* 11 */
  785. /***/ function(module, exports) {
  786. 'use strict';
  787. /**
  788. * Update an Error with the specified config, error code, and response.
  789. *
  790. * @param {Error} error The error to update.
  791. * @param {Object} config The config.
  792. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  793. * @param {Object} [request] The request.
  794. * @param {Object} [response] The response.
  795. * @returns {Error} The error.
  796. */
  797. module.exports = function enhanceError(error, config, code, request, response) {
  798. error.config = config;
  799. if (code) {
  800. error.code = code;
  801. }
  802. error.request = request;
  803. error.response = response;
  804. return error;
  805. };
  806. /***/ },
  807. /* 12 */
  808. /***/ function(module, exports, __webpack_require__) {
  809. 'use strict';
  810. var utils = __webpack_require__(2);
  811. function encode(val) {
  812. return encodeURIComponent(val).
  813. replace(/%40/gi, '@').
  814. replace(/%3A/gi, ':').
  815. replace(/%24/g, '$').
  816. replace(/%2C/gi, ',').
  817. replace(/%20/g, '+').
  818. replace(/%5B/gi, '[').
  819. replace(/%5D/gi, ']');
  820. }
  821. /**
  822. * Build a URL by appending params to the end
  823. *
  824. * @param {string} url The base of the url (e.g., http://www.google.com)
  825. * @param {object} [params] The params to be appended
  826. * @returns {string} The formatted url
  827. */
  828. module.exports = function buildURL(url, params, paramsSerializer) {
  829. /*eslint no-param-reassign:0*/
  830. if (!params) {
  831. return url;
  832. }
  833. var serializedParams;
  834. if (paramsSerializer) {
  835. serializedParams = paramsSerializer(params);
  836. } else if (utils.isURLSearchParams(params)) {
  837. serializedParams = params.toString();
  838. } else {
  839. var parts = [];
  840. utils.forEach(params, function serialize(val, key) {
  841. if (val === null || typeof val === 'undefined') {
  842. return;
  843. }
  844. if (utils.isArray(val)) {
  845. key = key + '[]';
  846. }
  847. if (!utils.isArray(val)) {
  848. val = [val];
  849. }
  850. utils.forEach(val, function parseValue(v) {
  851. if (utils.isDate(v)) {
  852. v = v.toISOString();
  853. } else if (utils.isObject(v)) {
  854. v = JSON.stringify(v);
  855. }
  856. parts.push(encode(key) + '=' + encode(v));
  857. });
  858. });
  859. serializedParams = parts.join('&');
  860. }
  861. if (serializedParams) {
  862. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  863. }
  864. return url;
  865. };
  866. /***/ },
  867. /* 13 */
  868. /***/ function(module, exports, __webpack_require__) {
  869. 'use strict';
  870. var utils = __webpack_require__(2);
  871. /**
  872. * Parse headers into an object
  873. *
  874. * ```
  875. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  876. * Content-Type: application/json
  877. * Connection: keep-alive
  878. * Transfer-Encoding: chunked
  879. * ```
  880. *
  881. * @param {String} headers Headers needing to be parsed
  882. * @returns {Object} Headers parsed into an object
  883. */
  884. module.exports = function parseHeaders(headers) {
  885. var parsed = {};
  886. var key;
  887. var val;
  888. var i;
  889. if (!headers) { return parsed; }
  890. utils.forEach(headers.split('\n'), function parser(line) {
  891. i = line.indexOf(':');
  892. key = utils.trim(line.substr(0, i)).toLowerCase();
  893. val = utils.trim(line.substr(i + 1));
  894. if (key) {
  895. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  896. }
  897. });
  898. return parsed;
  899. };
  900. /***/ },
  901. /* 14 */
  902. /***/ function(module, exports, __webpack_require__) {
  903. 'use strict';
  904. var utils = __webpack_require__(2);
  905. module.exports = (
  906. utils.isStandardBrowserEnv() ?
  907. // Standard browser envs have full support of the APIs needed to test
  908. // whether the request URL is of the same origin as current location.
  909. (function standardBrowserEnv() {
  910. var msie = /(msie|trident)/i.test(navigator.userAgent);
  911. var urlParsingNode = document.createElement('a');
  912. var originURL;
  913. /**
  914. * Parse a URL to discover it's components
  915. *
  916. * @param {String} url The URL to be parsed
  917. * @returns {Object}
  918. */
  919. function resolveURL(url) {
  920. var href = url;
  921. if (msie) {
  922. // IE needs attribute set twice to normalize properties
  923. urlParsingNode.setAttribute('href', href);
  924. href = urlParsingNode.href;
  925. }
  926. urlParsingNode.setAttribute('href', href);
  927. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  928. return {
  929. href: urlParsingNode.href,
  930. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  931. host: urlParsingNode.host,
  932. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  933. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  934. hostname: urlParsingNode.hostname,
  935. port: urlParsingNode.port,
  936. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  937. urlParsingNode.pathname :
  938. '/' + urlParsingNode.pathname
  939. };
  940. }
  941. originURL = resolveURL(window.location.href);
  942. /**
  943. * Determine if a URL shares the same origin as the current location
  944. *
  945. * @param {String} requestURL The URL to test
  946. * @returns {boolean} True if URL shares the same origin, otherwise false
  947. */
  948. return function isURLSameOrigin(requestURL) {
  949. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  950. return (parsed.protocol === originURL.protocol &&
  951. parsed.host === originURL.host);
  952. };
  953. })() :
  954. // Non standard browser envs (web workers, react-native) lack needed support.
  955. (function nonStandardBrowserEnv() {
  956. return function isURLSameOrigin() {
  957. return true;
  958. };
  959. })()
  960. );
  961. /***/ },
  962. /* 15 */
  963. /***/ function(module, exports) {
  964. 'use strict';
  965. // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
  966. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  967. function E() {
  968. this.message = 'String contains an invalid character';
  969. }
  970. E.prototype = new Error;
  971. E.prototype.code = 5;
  972. E.prototype.name = 'InvalidCharacterError';
  973. function btoa(input) {
  974. var str = String(input);
  975. var output = '';
  976. for (
  977. // initialize result and counter
  978. var block, charCode, idx = 0, map = chars;
  979. // if the next str index does not exist:
  980. // change the mapping table to "="
  981. // check if d has no fractional digits
  982. str.charAt(idx | 0) || (map = '=', idx % 1);
  983. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  984. output += map.charAt(63 & block >> 8 - idx % 1 * 8)
  985. ) {
  986. charCode = str.charCodeAt(idx += 3 / 4);
  987. if (charCode > 0xFF) {
  988. throw new E();
  989. }
  990. block = block << 8 | charCode;
  991. }
  992. return output;
  993. }
  994. module.exports = btoa;
  995. /***/ },
  996. /* 16 */
  997. /***/ function(module, exports, __webpack_require__) {
  998. 'use strict';
  999. var utils = __webpack_require__(2);
  1000. module.exports = (
  1001. utils.isStandardBrowserEnv() ?
  1002. // Standard browser envs support document.cookie
  1003. (function standardBrowserEnv() {
  1004. return {
  1005. write: function write(name, value, expires, path, domain, secure) {
  1006. var cookie = [];
  1007. cookie.push(name + '=' + encodeURIComponent(value));
  1008. if (utils.isNumber(expires)) {
  1009. cookie.push('expires=' + new Date(expires).toGMTString());
  1010. }
  1011. if (utils.isString(path)) {
  1012. cookie.push('path=' + path);
  1013. }
  1014. if (utils.isString(domain)) {
  1015. cookie.push('domain=' + domain);
  1016. }
  1017. if (secure === true) {
  1018. cookie.push('secure');
  1019. }
  1020. document.cookie = cookie.join('; ');
  1021. },
  1022. read: function read(name) {
  1023. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1024. return (match ? decodeURIComponent(match[3]) : null);
  1025. },
  1026. remove: function remove(name) {
  1027. this.write(name, '', Date.now() - 86400000);
  1028. }
  1029. };
  1030. })() :
  1031. // Non standard browser env (web workers, react-native) lack needed support.
  1032. (function nonStandardBrowserEnv() {
  1033. return {
  1034. write: function write() {},
  1035. read: function read() { return null; },
  1036. remove: function remove() {}
  1037. };
  1038. })()
  1039. );
  1040. /***/ },
  1041. /* 17 */
  1042. /***/ function(module, exports, __webpack_require__) {
  1043. 'use strict';
  1044. var utils = __webpack_require__(2);
  1045. function InterceptorManager() {
  1046. this.handlers = [];
  1047. }
  1048. /**
  1049. * Add a new interceptor to the stack
  1050. *
  1051. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1052. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1053. *
  1054. * @return {Number} An ID used to remove interceptor later
  1055. */
  1056. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  1057. this.handlers.push({
  1058. fulfilled: fulfilled,
  1059. rejected: rejected
  1060. });
  1061. return this.handlers.length - 1;
  1062. };
  1063. /**
  1064. * Remove an interceptor from the stack
  1065. *
  1066. * @param {Number} id The ID that was returned by `use`
  1067. */
  1068. InterceptorManager.prototype.eject = function eject(id) {
  1069. if (this.handlers[id]) {
  1070. this.handlers[id] = null;
  1071. }
  1072. };
  1073. /**
  1074. * Iterate over all the registered interceptors
  1075. *
  1076. * This method is particularly useful for skipping over any
  1077. * interceptors that may have become `null` calling `eject`.
  1078. *
  1079. * @param {Function} fn The function to call for each interceptor
  1080. */
  1081. InterceptorManager.prototype.forEach = function forEach(fn) {
  1082. utils.forEach(this.handlers, function forEachHandler(h) {
  1083. if (h !== null) {
  1084. fn(h);
  1085. }
  1086. });
  1087. };
  1088. module.exports = InterceptorManager;
  1089. /***/ },
  1090. /* 18 */
  1091. /***/ function(module, exports, __webpack_require__) {
  1092. 'use strict';
  1093. var utils = __webpack_require__(2);
  1094. var transformData = __webpack_require__(19);
  1095. var isCancel = __webpack_require__(20);
  1096. var defaults = __webpack_require__(6);
  1097. /**
  1098. * Throws a `Cancel` if cancellation has been requested.
  1099. */
  1100. function throwIfCancellationRequested(config) {
  1101. if (config.cancelToken) {
  1102. config.cancelToken.throwIfRequested();
  1103. }
  1104. }
  1105. /**
  1106. * Dispatch a request to the server using the configured adapter.
  1107. *
  1108. * @param {object} config The config that is to be used for the request
  1109. * @returns {Promise} The Promise to be fulfilled
  1110. */
  1111. module.exports = function dispatchRequest(config) {
  1112. throwIfCancellationRequested(config);
  1113. // Ensure headers exist
  1114. config.headers = config.headers || {};
  1115. // Transform request data
  1116. config.data = transformData(
  1117. config.data,
  1118. config.headers,
  1119. config.transformRequest
  1120. );
  1121. // Flatten headers
  1122. config.headers = utils.merge(
  1123. config.headers.common || {},
  1124. config.headers[config.method] || {},
  1125. config.headers || {}
  1126. );
  1127. utils.forEach(
  1128. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  1129. function cleanHeaderConfig(method) {
  1130. delete config.headers[method];
  1131. }
  1132. );
  1133. var adapter = config.adapter || defaults.adapter;
  1134. return adapter(config).then(function onAdapterResolution(response) {
  1135. throwIfCancellationRequested(config);
  1136. // Transform response data
  1137. response.data = transformData(
  1138. response.data,
  1139. response.headers,
  1140. config.transformResponse
  1141. );
  1142. return response;
  1143. }, function onAdapterRejection(reason) {
  1144. if (!isCancel(reason)) {
  1145. throwIfCancellationRequested(config);
  1146. // Transform response data
  1147. if (reason && reason.response) {
  1148. reason.response.data = transformData(
  1149. reason.response.data,
  1150. reason.response.headers,
  1151. config.transformResponse
  1152. );
  1153. }
  1154. }
  1155. return Promise.reject(reason);
  1156. });
  1157. };
  1158. /***/ },
  1159. /* 19 */
  1160. /***/ function(module, exports, __webpack_require__) {
  1161. 'use strict';
  1162. var utils = __webpack_require__(2);
  1163. /**
  1164. * Transform the data for a request or a response
  1165. *
  1166. * @param {Object|String} data The data to be transformed
  1167. * @param {Array} headers The headers for the request or response
  1168. * @param {Array|Function} fns A single function or Array of functions
  1169. * @returns {*} The resulting transformed data
  1170. */
  1171. module.exports = function transformData(data, headers, fns) {
  1172. /*eslint no-param-reassign:0*/
  1173. utils.forEach(fns, function transform(fn) {
  1174. data = fn(data, headers);
  1175. });
  1176. return data;
  1177. };
  1178. /***/ },
  1179. /* 20 */
  1180. /***/ function(module, exports) {
  1181. 'use strict';
  1182. module.exports = function isCancel(value) {
  1183. return !!(value && value.__CANCEL__);
  1184. };
  1185. /***/ },
  1186. /* 21 */
  1187. /***/ function(module, exports) {
  1188. 'use strict';
  1189. /**
  1190. * Determines whether the specified URL is absolute
  1191. *
  1192. * @param {string} url The URL to test
  1193. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1194. */
  1195. module.exports = function isAbsoluteURL(url) {
  1196. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1197. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1198. // by any combination of letters, digits, plus, period, or hyphen.
  1199. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1200. };
  1201. /***/ },
  1202. /* 22 */
  1203. /***/ function(module, exports) {
  1204. 'use strict';
  1205. /**
  1206. * Creates a new URL by combining the specified URLs
  1207. *
  1208. * @param {string} baseURL The base URL
  1209. * @param {string} relativeURL The relative URL
  1210. * @returns {string} The combined URL
  1211. */
  1212. module.exports = function combineURLs(baseURL, relativeURL) {
  1213. return relativeURL
  1214. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1215. : baseURL;
  1216. };
  1217. /***/ },
  1218. /* 23 */
  1219. /***/ function(module, exports) {
  1220. 'use strict';
  1221. /**
  1222. * A `Cancel` is an object that is thrown when an operation is canceled.
  1223. *
  1224. * @class
  1225. * @param {string=} message The message.
  1226. */
  1227. function Cancel(message) {
  1228. this.message = message;
  1229. }
  1230. Cancel.prototype.toString = function toString() {
  1231. return 'Cancel' + (this.message ? ': ' + this.message : '');
  1232. };
  1233. Cancel.prototype.__CANCEL__ = true;
  1234. module.exports = Cancel;
  1235. /***/ },
  1236. /* 24 */
  1237. /***/ function(module, exports, __webpack_require__) {
  1238. 'use strict';
  1239. var Cancel = __webpack_require__(23);
  1240. /**
  1241. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  1242. *
  1243. * @class
  1244. * @param {Function} executor The executor function.
  1245. */
  1246. function CancelToken(executor) {
  1247. if (typeof executor !== 'function') {
  1248. throw new TypeError('executor must be a function.');
  1249. }
  1250. var resolvePromise;
  1251. this.promise = new Promise(function promiseExecutor(resolve) {
  1252. resolvePromise = resolve;
  1253. });
  1254. var token = this;
  1255. executor(function cancel(message) {
  1256. if (token.reason) {
  1257. // Cancellation has already been requested
  1258. return;
  1259. }
  1260. token.reason = new Cancel(message);
  1261. resolvePromise(token.reason);
  1262. });
  1263. }
  1264. /**
  1265. * Throws a `Cancel` if cancellation has been requested.
  1266. */
  1267. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  1268. if (this.reason) {
  1269. throw this.reason;
  1270. }
  1271. };
  1272. /**
  1273. * Returns an object that contains a new `CancelToken` and a function that, when called,
  1274. * cancels the `CancelToken`.
  1275. */
  1276. CancelToken.source = function source() {
  1277. var cancel;
  1278. var token = new CancelToken(function executor(c) {
  1279. cancel = c;
  1280. });
  1281. return {
  1282. token: token,
  1283. cancel: cancel
  1284. };
  1285. };
  1286. module.exports = CancelToken;
  1287. /***/ },
  1288. /* 25 */
  1289. /***/ function(module, exports) {
  1290. 'use strict';
  1291. /**
  1292. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1293. *
  1294. * Common use case would be to use `Function.prototype.apply`.
  1295. *
  1296. * ```js
  1297. * function f(x, y, z) {}
  1298. * var args = [1, 2, 3];
  1299. * f.apply(null, args);
  1300. * ```
  1301. *
  1302. * With `spread` this example can be re-written.
  1303. *
  1304. * ```js
  1305. * spread(function(x, y, z) {})([1, 2, 3]);
  1306. * ```
  1307. *
  1308. * @param {Function} callback
  1309. * @returns {Function}
  1310. */
  1311. module.exports = function spread(callback) {
  1312. return function wrap(arr) {
  1313. return callback.apply(null, arr);
  1314. };
  1315. };
  1316. /***/ }
  1317. /******/ ])
  1318. });
  1319. ;
  1320. //# sourceMappingURL=axios.map