axios.js 42 KB

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