axios.js 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["axios"] = factory();
  8. else
  9. root["axios"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./index.js");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./index.js":
  99. /*!******************!*\
  100. !*** ./index.js ***!
  101. \******************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. module.exports = __webpack_require__(/*! ./lib/axios */ "./lib/axios.js");
  105. /***/ }),
  106. /***/ "./lib/adapters/xhr.js":
  107. /*!*****************************!*\
  108. !*** ./lib/adapters/xhr.js ***!
  109. \*****************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports, __webpack_require__) {
  112. "use strict";
  113. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  114. var settle = __webpack_require__(/*! ./../core/settle */ "./lib/core/settle.js");
  115. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./lib/helpers/cookies.js");
  116. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/buildURL.js");
  117. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
  118. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
  119. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
  120. var createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
  121. var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
  122. var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
  123. module.exports = function xhrAdapter(config) {
  124. return new Promise(function dispatchXhrRequest(resolve, reject) {
  125. var requestData = config.data;
  126. var requestHeaders = config.headers;
  127. var responseType = config.responseType;
  128. var onCanceled;
  129. function done() {
  130. if (config.cancelToken) {
  131. config.cancelToken.unsubscribe(onCanceled);
  132. }
  133. if (config.signal) {
  134. config.signal.removeEventListener('abort', onCanceled);
  135. }
  136. }
  137. if (utils.isFormData(requestData)) {
  138. delete requestHeaders['Content-Type']; // Let the browser set it
  139. }
  140. var request = new XMLHttpRequest();
  141. // HTTP basic authentication
  142. if (config.auth) {
  143. var username = config.auth.username || '';
  144. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  145. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  146. }
  147. var fullPath = buildFullPath(config.baseURL, config.url);
  148. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  149. // Set the request timeout in MS
  150. request.timeout = config.timeout;
  151. function onloadend() {
  152. if (!request) {
  153. return;
  154. }
  155. // Prepare the response
  156. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  157. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  158. request.responseText : request.response;
  159. var response = {
  160. data: responseData,
  161. status: request.status,
  162. statusText: request.statusText,
  163. headers: responseHeaders,
  164. config: config,
  165. request: request
  166. };
  167. settle(function _resolve(value) {
  168. resolve(value);
  169. done();
  170. }, function _reject(err) {
  171. reject(err);
  172. done();
  173. }, response);
  174. // Clean up request
  175. request = null;
  176. }
  177. if ('onloadend' in request) {
  178. // Use onloadend if available
  179. request.onloadend = onloadend;
  180. } else {
  181. // Listen for ready state to emulate onloadend
  182. request.onreadystatechange = function handleLoad() {
  183. if (!request || request.readyState !== 4) {
  184. return;
  185. }
  186. // The request errored out and we didn't get a response, this will be
  187. // handled by onerror instead
  188. // With one exception: request that using file: protocol, most browsers
  189. // will return status as 0 even though it's a successful request
  190. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  191. return;
  192. }
  193. // readystate handler is calling before onerror or ontimeout handlers,
  194. // so we should call onloadend on the next 'tick'
  195. setTimeout(onloadend);
  196. };
  197. }
  198. // Handle browser request cancellation (as opposed to a manual cancellation)
  199. request.onabort = function handleAbort() {
  200. if (!request) {
  201. return;
  202. }
  203. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  204. // Clean up request
  205. request = null;
  206. };
  207. // Handle low level network errors
  208. request.onerror = function handleError() {
  209. // Real errors are hidden from us by the browser
  210. // onerror should only fire if it's a network error
  211. reject(createError('Network Error', config, null, request));
  212. // Clean up request
  213. request = null;
  214. };
  215. // Handle timeout
  216. request.ontimeout = function handleTimeout() {
  217. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  218. var transitional = config.transitional || defaults.transitional;
  219. if (config.timeoutErrorMessage) {
  220. timeoutErrorMessage = config.timeoutErrorMessage;
  221. }
  222. reject(createError(
  223. timeoutErrorMessage,
  224. config,
  225. transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  226. request));
  227. // Clean up request
  228. request = null;
  229. };
  230. // Add xsrf header
  231. // This is only done if running in a standard browser environment.
  232. // Specifically not if we're in a web worker, or react-native.
  233. if (utils.isStandardBrowserEnv()) {
  234. // Add xsrf header
  235. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  236. cookies.read(config.xsrfCookieName) :
  237. undefined;
  238. if (xsrfValue) {
  239. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  240. }
  241. }
  242. // Add headers to the request
  243. if ('setRequestHeader' in request) {
  244. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  245. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  246. // Remove Content-Type if data is undefined
  247. delete requestHeaders[key];
  248. } else {
  249. // Otherwise add header to the request
  250. request.setRequestHeader(key, val);
  251. }
  252. });
  253. }
  254. // Add withCredentials to request if needed
  255. if (!utils.isUndefined(config.withCredentials)) {
  256. request.withCredentials = !!config.withCredentials;
  257. }
  258. // Add responseType to request if needed
  259. if (responseType && responseType !== 'json') {
  260. request.responseType = config.responseType;
  261. }
  262. // Handle progress if needed
  263. if (typeof config.onDownloadProgress === 'function') {
  264. request.addEventListener('progress', config.onDownloadProgress);
  265. }
  266. // Not all browsers support upload events
  267. if (typeof config.onUploadProgress === 'function' && request.upload) {
  268. request.upload.addEventListener('progress', config.onUploadProgress);
  269. }
  270. if (config.cancelToken || config.signal) {
  271. // Handle cancellation
  272. // eslint-disable-next-line func-names
  273. onCanceled = function(cancel) {
  274. if (!request) {
  275. return;
  276. }
  277. reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
  278. request.abort();
  279. request = null;
  280. };
  281. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  282. if (config.signal) {
  283. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  284. }
  285. }
  286. if (!requestData) {
  287. requestData = null;
  288. }
  289. // Send the request
  290. request.send(requestData);
  291. });
  292. };
  293. /***/ }),
  294. /***/ "./lib/axios.js":
  295. /*!**********************!*\
  296. !*** ./lib/axios.js ***!
  297. \**********************/
  298. /*! no static exports found */
  299. /***/ (function(module, exports, __webpack_require__) {
  300. "use strict";
  301. var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
  302. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  303. var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
  304. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
  305. var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults.js");
  306. /**
  307. * Create an instance of Axios
  308. *
  309. * @param {Object} defaultConfig The default config for the instance
  310. * @return {Axios} A new instance of Axios
  311. */
  312. function createInstance(defaultConfig) {
  313. var context = new Axios(defaultConfig);
  314. var instance = bind(Axios.prototype.request, context);
  315. // Copy axios.prototype to instance
  316. utils.extend(instance, Axios.prototype, context);
  317. // Copy context to instance
  318. utils.extend(instance, context);
  319. // Factory for creating new instances
  320. instance.create = function create(instanceConfig) {
  321. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  322. };
  323. return instance;
  324. }
  325. // Create the default instance to be exported
  326. var axios = createInstance(defaults);
  327. // Expose Axios class to allow class inheritance
  328. axios.Axios = Axios;
  329. // Expose Cancel & CancelToken
  330. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./lib/cancel/Cancel.js");
  331. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
  332. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
  333. axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
  334. // Expose all/spread
  335. axios.all = function all(promises) {
  336. return Promise.all(promises);
  337. };
  338. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./lib/helpers/spread.js");
  339. // Expose isAxiosError
  340. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./lib/helpers/isAxiosError.js");
  341. module.exports = axios;
  342. // Allow use of default import syntax in TypeScript
  343. module.exports.default = axios;
  344. /***/ }),
  345. /***/ "./lib/cancel/Cancel.js":
  346. /*!******************************!*\
  347. !*** ./lib/cancel/Cancel.js ***!
  348. \******************************/
  349. /*! no static exports found */
  350. /***/ (function(module, exports, __webpack_require__) {
  351. "use strict";
  352. /**
  353. * A `Cancel` is an object that is thrown when an operation is canceled.
  354. *
  355. * @class
  356. * @param {string=} message The message.
  357. */
  358. function Cancel(message) {
  359. this.message = message;
  360. }
  361. Cancel.prototype.toString = function toString() {
  362. return 'Cancel' + (this.message ? ': ' + this.message : '');
  363. };
  364. Cancel.prototype.__CANCEL__ = true;
  365. module.exports = Cancel;
  366. /***/ }),
  367. /***/ "./lib/cancel/CancelToken.js":
  368. /*!***********************************!*\
  369. !*** ./lib/cancel/CancelToken.js ***!
  370. \***********************************/
  371. /*! no static exports found */
  372. /***/ (function(module, exports, __webpack_require__) {
  373. "use strict";
  374. var Cancel = __webpack_require__(/*! ./Cancel */ "./lib/cancel/Cancel.js");
  375. /**
  376. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  377. *
  378. * @class
  379. * @param {Function} executor The executor function.
  380. */
  381. function CancelToken(executor) {
  382. if (typeof executor !== 'function') {
  383. throw new TypeError('executor must be a function.');
  384. }
  385. var resolvePromise;
  386. this.promise = new Promise(function promiseExecutor(resolve) {
  387. resolvePromise = resolve;
  388. });
  389. var token = this;
  390. // eslint-disable-next-line func-names
  391. this.promise.then(function(cancel) {
  392. if (!token._listeners) return;
  393. var i;
  394. var l = token._listeners.length;
  395. for (i = 0; i < l; i++) {
  396. token._listeners[i](cancel);
  397. }
  398. token._listeners = null;
  399. });
  400. // eslint-disable-next-line func-names
  401. this.promise.then = function(onfulfilled) {
  402. var _resolve;
  403. // eslint-disable-next-line func-names
  404. var promise = new Promise(function(resolve) {
  405. token.subscribe(resolve);
  406. _resolve = resolve;
  407. }).then(onfulfilled);
  408. promise.cancel = function reject() {
  409. token.unsubscribe(_resolve);
  410. };
  411. return promise;
  412. };
  413. executor(function cancel(message) {
  414. if (token.reason) {
  415. // Cancellation has already been requested
  416. return;
  417. }
  418. token.reason = new Cancel(message);
  419. resolvePromise(token.reason);
  420. });
  421. }
  422. /**
  423. * Throws a `Cancel` if cancellation has been requested.
  424. */
  425. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  426. if (this.reason) {
  427. throw this.reason;
  428. }
  429. };
  430. /**
  431. * Subscribe to the cancel signal
  432. */
  433. CancelToken.prototype.subscribe = function subscribe(listener) {
  434. if (this.reason) {
  435. listener(this.reason);
  436. return;
  437. }
  438. if (this._listeners) {
  439. this._listeners.push(listener);
  440. } else {
  441. this._listeners = [listener];
  442. }
  443. };
  444. /**
  445. * Unsubscribe from the cancel signal
  446. */
  447. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  448. if (!this._listeners) {
  449. return;
  450. }
  451. var index = this._listeners.indexOf(listener);
  452. if (index !== -1) {
  453. this._listeners.splice(index, 1);
  454. }
  455. };
  456. /**
  457. * Returns an object that contains a new `CancelToken` and a function that, when called,
  458. * cancels the `CancelToken`.
  459. */
  460. CancelToken.source = function source() {
  461. var cancel;
  462. var token = new CancelToken(function executor(c) {
  463. cancel = c;
  464. });
  465. return {
  466. token: token,
  467. cancel: cancel
  468. };
  469. };
  470. module.exports = CancelToken;
  471. /***/ }),
  472. /***/ "./lib/cancel/isCancel.js":
  473. /*!********************************!*\
  474. !*** ./lib/cancel/isCancel.js ***!
  475. \********************************/
  476. /*! no static exports found */
  477. /***/ (function(module, exports, __webpack_require__) {
  478. "use strict";
  479. module.exports = function isCancel(value) {
  480. return !!(value && value.__CANCEL__);
  481. };
  482. /***/ }),
  483. /***/ "./lib/core/Axios.js":
  484. /*!***************************!*\
  485. !*** ./lib/core/Axios.js ***!
  486. \***************************/
  487. /*! no static exports found */
  488. /***/ (function(module, exports, __webpack_require__) {
  489. "use strict";
  490. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  491. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/buildURL.js");
  492. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
  493. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
  494. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
  495. var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
  496. var validators = validator.validators;
  497. /**
  498. * Create a new instance of Axios
  499. *
  500. * @param {Object} instanceConfig The default config for the instance
  501. */
  502. function Axios(instanceConfig) {
  503. this.defaults = instanceConfig;
  504. this.interceptors = {
  505. request: new InterceptorManager(),
  506. response: new InterceptorManager()
  507. };
  508. }
  509. /**
  510. * Dispatch a request
  511. *
  512. * @param {Object} config The config specific for this request (merged with this.defaults)
  513. */
  514. Axios.prototype.request = function request(configOrUrl, config) {
  515. /*eslint no-param-reassign:0*/
  516. // Allow for axios('example/url'[, config]) a la fetch API
  517. if (typeof configOrUrl === 'string') {
  518. config = config || {};
  519. config.url = configOrUrl;
  520. } else {
  521. config = configOrUrl || {};
  522. }
  523. config = mergeConfig(this.defaults, config);
  524. // Set config.method
  525. if (config.method) {
  526. config.method = config.method.toLowerCase();
  527. } else if (this.defaults.method) {
  528. config.method = this.defaults.method.toLowerCase();
  529. } else {
  530. config.method = 'get';
  531. }
  532. var transitional = config.transitional;
  533. if (transitional !== undefined) {
  534. validator.assertOptions(transitional, {
  535. silentJSONParsing: validators.transitional(validators.boolean),
  536. forcedJSONParsing: validators.transitional(validators.boolean),
  537. clarifyTimeoutError: validators.transitional(validators.boolean)
  538. }, false);
  539. }
  540. // filter out skipped interceptors
  541. var requestInterceptorChain = [];
  542. var synchronousRequestInterceptors = true;
  543. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  544. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  545. return;
  546. }
  547. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  548. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  549. });
  550. var responseInterceptorChain = [];
  551. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  552. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  553. });
  554. var promise;
  555. if (!synchronousRequestInterceptors) {
  556. var chain = [dispatchRequest, undefined];
  557. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  558. chain = chain.concat(responseInterceptorChain);
  559. promise = Promise.resolve(config);
  560. while (chain.length) {
  561. promise = promise.then(chain.shift(), chain.shift());
  562. }
  563. return promise;
  564. }
  565. var newConfig = config;
  566. while (requestInterceptorChain.length) {
  567. var onFulfilled = requestInterceptorChain.shift();
  568. var onRejected = requestInterceptorChain.shift();
  569. try {
  570. newConfig = onFulfilled(newConfig);
  571. } catch (error) {
  572. onRejected(error);
  573. break;
  574. }
  575. }
  576. try {
  577. promise = dispatchRequest(newConfig);
  578. } catch (error) {
  579. return Promise.reject(error);
  580. }
  581. while (responseInterceptorChain.length) {
  582. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  583. }
  584. return promise;
  585. };
  586. Axios.prototype.getUri = function getUri(config) {
  587. config = mergeConfig(this.defaults, config);
  588. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  589. };
  590. // Provide aliases for supported request methods
  591. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  592. /*eslint func-names:0*/
  593. Axios.prototype[method] = function(url, config) {
  594. return this.request(mergeConfig(config || {}, {
  595. method: method,
  596. url: url,
  597. data: (config || {}).data
  598. }));
  599. };
  600. });
  601. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  602. /*eslint func-names:0*/
  603. Axios.prototype[method] = function(url, data, config) {
  604. return this.request(mergeConfig(config || {}, {
  605. method: method,
  606. url: url,
  607. data: data
  608. }));
  609. };
  610. });
  611. module.exports = Axios;
  612. /***/ }),
  613. /***/ "./lib/core/InterceptorManager.js":
  614. /*!****************************************!*\
  615. !*** ./lib/core/InterceptorManager.js ***!
  616. \****************************************/
  617. /*! no static exports found */
  618. /***/ (function(module, exports, __webpack_require__) {
  619. "use strict";
  620. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  621. function InterceptorManager() {
  622. this.handlers = [];
  623. }
  624. /**
  625. * Add a new interceptor to the stack
  626. *
  627. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  628. * @param {Function} rejected The function to handle `reject` for a `Promise`
  629. *
  630. * @return {Number} An ID used to remove interceptor later
  631. */
  632. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  633. this.handlers.push({
  634. fulfilled: fulfilled,
  635. rejected: rejected,
  636. synchronous: options ? options.synchronous : false,
  637. runWhen: options ? options.runWhen : null
  638. });
  639. return this.handlers.length - 1;
  640. };
  641. /**
  642. * Remove an interceptor from the stack
  643. *
  644. * @param {Number} id The ID that was returned by `use`
  645. */
  646. InterceptorManager.prototype.eject = function eject(id) {
  647. if (this.handlers[id]) {
  648. this.handlers[id] = null;
  649. }
  650. };
  651. /**
  652. * Iterate over all the registered interceptors
  653. *
  654. * This method is particularly useful for skipping over any
  655. * interceptors that may have become `null` calling `eject`.
  656. *
  657. * @param {Function} fn The function to call for each interceptor
  658. */
  659. InterceptorManager.prototype.forEach = function forEach(fn) {
  660. utils.forEach(this.handlers, function forEachHandler(h) {
  661. if (h !== null) {
  662. fn(h);
  663. }
  664. });
  665. };
  666. module.exports = InterceptorManager;
  667. /***/ }),
  668. /***/ "./lib/core/buildFullPath.js":
  669. /*!***********************************!*\
  670. !*** ./lib/core/buildFullPath.js ***!
  671. \***********************************/
  672. /*! no static exports found */
  673. /***/ (function(module, exports, __webpack_require__) {
  674. "use strict";
  675. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./lib/helpers/isAbsoluteURL.js");
  676. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./lib/helpers/combineURLs.js");
  677. /**
  678. * Creates a new URL by combining the baseURL with the requestedURL,
  679. * only when the requestedURL is not already an absolute URL.
  680. * If the requestURL is absolute, this function returns the requestedURL untouched.
  681. *
  682. * @param {string} baseURL The base URL
  683. * @param {string} requestedURL Absolute or relative URL to combine
  684. * @returns {string} The combined full path
  685. */
  686. module.exports = function buildFullPath(baseURL, requestedURL) {
  687. if (baseURL && !isAbsoluteURL(requestedURL)) {
  688. return combineURLs(baseURL, requestedURL);
  689. }
  690. return requestedURL;
  691. };
  692. /***/ }),
  693. /***/ "./lib/core/createError.js":
  694. /*!*********************************!*\
  695. !*** ./lib/core/createError.js ***!
  696. \*********************************/
  697. /*! no static exports found */
  698. /***/ (function(module, exports, __webpack_require__) {
  699. "use strict";
  700. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./lib/core/enhanceError.js");
  701. /**
  702. * Create an Error with the specified message, config, error code, request and response.
  703. *
  704. * @param {string} message The error message.
  705. * @param {Object} config The config.
  706. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  707. * @param {Object} [request] The request.
  708. * @param {Object} [response] The response.
  709. * @returns {Error} The created error.
  710. */
  711. module.exports = function createError(message, config, code, request, response) {
  712. var error = new Error(message);
  713. return enhanceError(error, config, code, request, response);
  714. };
  715. /***/ }),
  716. /***/ "./lib/core/dispatchRequest.js":
  717. /*!*************************************!*\
  718. !*** ./lib/core/dispatchRequest.js ***!
  719. \*************************************/
  720. /*! no static exports found */
  721. /***/ (function(module, exports, __webpack_require__) {
  722. "use strict";
  723. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  724. var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
  725. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
  726. var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
  727. var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
  728. /**
  729. * Throws a `Cancel` if cancellation has been requested.
  730. */
  731. function throwIfCancellationRequested(config) {
  732. if (config.cancelToken) {
  733. config.cancelToken.throwIfRequested();
  734. }
  735. if (config.signal && config.signal.aborted) {
  736. throw new Cancel('canceled');
  737. }
  738. }
  739. /**
  740. * Dispatch a request to the server using the configured adapter.
  741. *
  742. * @param {object} config The config that is to be used for the request
  743. * @returns {Promise} The Promise to be fulfilled
  744. */
  745. module.exports = function dispatchRequest(config) {
  746. throwIfCancellationRequested(config);
  747. // Ensure headers exist
  748. config.headers = config.headers || {};
  749. // Transform request data
  750. config.data = transformData.call(
  751. config,
  752. config.data,
  753. config.headers,
  754. config.transformRequest
  755. );
  756. // Flatten headers
  757. config.headers = utils.merge(
  758. config.headers.common || {},
  759. config.headers[config.method] || {},
  760. config.headers
  761. );
  762. utils.forEach(
  763. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  764. function cleanHeaderConfig(method) {
  765. delete config.headers[method];
  766. }
  767. );
  768. var adapter = config.adapter || defaults.adapter;
  769. return adapter(config).then(function onAdapterResolution(response) {
  770. throwIfCancellationRequested(config);
  771. // Transform response data
  772. response.data = transformData.call(
  773. config,
  774. response.data,
  775. response.headers,
  776. config.transformResponse
  777. );
  778. return response;
  779. }, function onAdapterRejection(reason) {
  780. if (!isCancel(reason)) {
  781. throwIfCancellationRequested(config);
  782. // Transform response data
  783. if (reason && reason.response) {
  784. reason.response.data = transformData.call(
  785. config,
  786. reason.response.data,
  787. reason.response.headers,
  788. config.transformResponse
  789. );
  790. }
  791. }
  792. return Promise.reject(reason);
  793. });
  794. };
  795. /***/ }),
  796. /***/ "./lib/core/enhanceError.js":
  797. /*!**********************************!*\
  798. !*** ./lib/core/enhanceError.js ***!
  799. \**********************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. /**
  804. * Update an Error with the specified config, error code, and response.
  805. *
  806. * @param {Error} error The error to update.
  807. * @param {Object} config The config.
  808. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  809. * @param {Object} [request] The request.
  810. * @param {Object} [response] The response.
  811. * @returns {Error} The error.
  812. */
  813. module.exports = function enhanceError(error, config, code, request, response) {
  814. error.config = config;
  815. if (code) {
  816. error.code = code;
  817. }
  818. error.request = request;
  819. error.response = response;
  820. error.isAxiosError = true;
  821. error.toJSON = function toJSON() {
  822. return {
  823. // Standard
  824. message: this.message,
  825. name: this.name,
  826. // Microsoft
  827. description: this.description,
  828. number: this.number,
  829. // Mozilla
  830. fileName: this.fileName,
  831. lineNumber: this.lineNumber,
  832. columnNumber: this.columnNumber,
  833. stack: this.stack,
  834. // Axios
  835. config: this.config,
  836. code: this.code,
  837. status: this.response && this.response.status ? this.response.status : null
  838. };
  839. };
  840. return error;
  841. };
  842. /***/ }),
  843. /***/ "./lib/core/mergeConfig.js":
  844. /*!*********************************!*\
  845. !*** ./lib/core/mergeConfig.js ***!
  846. \*********************************/
  847. /*! no static exports found */
  848. /***/ (function(module, exports, __webpack_require__) {
  849. "use strict";
  850. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  851. /**
  852. * Config-specific merge-function which creates a new config-object
  853. * by merging two configuration objects together.
  854. *
  855. * @param {Object} config1
  856. * @param {Object} config2
  857. * @returns {Object} New object resulting from merging config2 to config1
  858. */
  859. module.exports = function mergeConfig(config1, config2) {
  860. // eslint-disable-next-line no-param-reassign
  861. config2 = config2 || {};
  862. var config = {};
  863. function getMergedValue(target, source) {
  864. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  865. return utils.merge(target, source);
  866. } else if (utils.isPlainObject(source)) {
  867. return utils.merge({}, source);
  868. } else if (utils.isArray(source)) {
  869. return source.slice();
  870. }
  871. return source;
  872. }
  873. // eslint-disable-next-line consistent-return
  874. function mergeDeepProperties(prop) {
  875. if (!utils.isUndefined(config2[prop])) {
  876. return getMergedValue(config1[prop], config2[prop]);
  877. } else if (!utils.isUndefined(config1[prop])) {
  878. return getMergedValue(undefined, config1[prop]);
  879. }
  880. }
  881. // eslint-disable-next-line consistent-return
  882. function valueFromConfig2(prop) {
  883. if (!utils.isUndefined(config2[prop])) {
  884. return getMergedValue(undefined, config2[prop]);
  885. }
  886. }
  887. // eslint-disable-next-line consistent-return
  888. function defaultToConfig2(prop) {
  889. if (!utils.isUndefined(config2[prop])) {
  890. return getMergedValue(undefined, config2[prop]);
  891. } else if (!utils.isUndefined(config1[prop])) {
  892. return getMergedValue(undefined, config1[prop]);
  893. }
  894. }
  895. // eslint-disable-next-line consistent-return
  896. function mergeDirectKeys(prop) {
  897. if (prop in config2) {
  898. return getMergedValue(config1[prop], config2[prop]);
  899. } else if (prop in config1) {
  900. return getMergedValue(undefined, config1[prop]);
  901. }
  902. }
  903. var mergeMap = {
  904. 'url': valueFromConfig2,
  905. 'method': valueFromConfig2,
  906. 'data': valueFromConfig2,
  907. 'baseURL': defaultToConfig2,
  908. 'transformRequest': defaultToConfig2,
  909. 'transformResponse': defaultToConfig2,
  910. 'paramsSerializer': defaultToConfig2,
  911. 'timeout': defaultToConfig2,
  912. 'timeoutMessage': defaultToConfig2,
  913. 'withCredentials': defaultToConfig2,
  914. 'adapter': defaultToConfig2,
  915. 'responseType': defaultToConfig2,
  916. 'xsrfCookieName': defaultToConfig2,
  917. 'xsrfHeaderName': defaultToConfig2,
  918. 'onUploadProgress': defaultToConfig2,
  919. 'onDownloadProgress': defaultToConfig2,
  920. 'decompress': defaultToConfig2,
  921. 'maxContentLength': defaultToConfig2,
  922. 'maxBodyLength': defaultToConfig2,
  923. 'transport': defaultToConfig2,
  924. 'httpAgent': defaultToConfig2,
  925. 'httpsAgent': defaultToConfig2,
  926. 'cancelToken': defaultToConfig2,
  927. 'socketPath': defaultToConfig2,
  928. 'responseEncoding': defaultToConfig2,
  929. 'validateStatus': mergeDirectKeys
  930. };
  931. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  932. var merge = mergeMap[prop] || mergeDeepProperties;
  933. var configValue = merge(prop);
  934. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  935. });
  936. return config;
  937. };
  938. /***/ }),
  939. /***/ "./lib/core/settle.js":
  940. /*!****************************!*\
  941. !*** ./lib/core/settle.js ***!
  942. \****************************/
  943. /*! no static exports found */
  944. /***/ (function(module, exports, __webpack_require__) {
  945. "use strict";
  946. var createError = __webpack_require__(/*! ./createError */ "./lib/core/createError.js");
  947. /**
  948. * Resolve or reject a Promise based on response status.
  949. *
  950. * @param {Function} resolve A function that resolves the promise.
  951. * @param {Function} reject A function that rejects the promise.
  952. * @param {object} response The response.
  953. */
  954. module.exports = function settle(resolve, reject, response) {
  955. var validateStatus = response.config.validateStatus;
  956. if (!response.status || !validateStatus || validateStatus(response.status)) {
  957. resolve(response);
  958. } else {
  959. reject(createError(
  960. 'Request failed with status code ' + response.status,
  961. response.config,
  962. null,
  963. response.request,
  964. response
  965. ));
  966. }
  967. };
  968. /***/ }),
  969. /***/ "./lib/core/transformData.js":
  970. /*!***********************************!*\
  971. !*** ./lib/core/transformData.js ***!
  972. \***********************************/
  973. /*! no static exports found */
  974. /***/ (function(module, exports, __webpack_require__) {
  975. "use strict";
  976. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  977. var defaults = __webpack_require__(/*! ./../defaults */ "./lib/defaults.js");
  978. /**
  979. * Transform the data for a request or a response
  980. *
  981. * @param {Object|String} data The data to be transformed
  982. * @param {Array} headers The headers for the request or response
  983. * @param {Array|Function} fns A single function or Array of functions
  984. * @returns {*} The resulting transformed data
  985. */
  986. module.exports = function transformData(data, headers, fns) {
  987. var context = this || defaults;
  988. /*eslint no-param-reassign:0*/
  989. utils.forEach(fns, function transform(fn) {
  990. data = fn.call(context, data, headers);
  991. });
  992. return data;
  993. };
  994. /***/ }),
  995. /***/ "./lib/defaults.js":
  996. /*!*************************!*\
  997. !*** ./lib/defaults.js ***!
  998. \*************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
  1003. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
  1004. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./lib/core/enhanceError.js");
  1005. var DEFAULT_CONTENT_TYPE = {
  1006. 'Content-Type': 'application/x-www-form-urlencoded'
  1007. };
  1008. function setContentTypeIfUnset(headers, value) {
  1009. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  1010. headers['Content-Type'] = value;
  1011. }
  1012. }
  1013. function getDefaultAdapter() {
  1014. var adapter;
  1015. if (typeof XMLHttpRequest !== 'undefined') {
  1016. // For browsers use XHR adapter
  1017. adapter = __webpack_require__(/*! ./adapters/xhr */ "./lib/adapters/xhr.js");
  1018. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  1019. // For node use HTTP adapter
  1020. adapter = __webpack_require__(/*! ./adapters/http */ "./lib/adapters/xhr.js");
  1021. }
  1022. return adapter;
  1023. }
  1024. function stringifySafely(rawValue, parser, encoder) {
  1025. if (utils.isString(rawValue)) {
  1026. try {
  1027. (parser || JSON.parse)(rawValue);
  1028. return utils.trim(rawValue);
  1029. } catch (e) {
  1030. if (e.name !== 'SyntaxError') {
  1031. throw e;
  1032. }
  1033. }
  1034. }
  1035. return (encoder || JSON.stringify)(rawValue);
  1036. }
  1037. var defaults = {
  1038. transitional: {
  1039. silentJSONParsing: true,
  1040. forcedJSONParsing: true,
  1041. clarifyTimeoutError: false
  1042. },
  1043. adapter: getDefaultAdapter(),
  1044. transformRequest: [function transformRequest(data, headers) {
  1045. normalizeHeaderName(headers, 'Accept');
  1046. normalizeHeaderName(headers, 'Content-Type');
  1047. if (utils.isFormData(data) ||
  1048. utils.isArrayBuffer(data) ||
  1049. utils.isBuffer(data) ||
  1050. utils.isStream(data) ||
  1051. utils.isFile(data) ||
  1052. utils.isBlob(data)
  1053. ) {
  1054. return data;
  1055. }
  1056. if (utils.isArrayBufferView(data)) {
  1057. return data.buffer;
  1058. }
  1059. if (utils.isURLSearchParams(data)) {
  1060. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1061. return data.toString();
  1062. }
  1063. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  1064. setContentTypeIfUnset(headers, 'application/json');
  1065. return stringifySafely(data);
  1066. }
  1067. return data;
  1068. }],
  1069. transformResponse: [function transformResponse(data) {
  1070. var transitional = this.transitional || defaults.transitional;
  1071. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  1072. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1073. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  1074. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  1075. try {
  1076. return JSON.parse(data);
  1077. } catch (e) {
  1078. if (strictJSONParsing) {
  1079. if (e.name === 'SyntaxError') {
  1080. throw enhanceError(e, this, 'E_JSON_PARSE');
  1081. }
  1082. throw e;
  1083. }
  1084. }
  1085. }
  1086. return data;
  1087. }],
  1088. /**
  1089. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1090. * timeout is not created.
  1091. */
  1092. timeout: 0,
  1093. xsrfCookieName: 'XSRF-TOKEN',
  1094. xsrfHeaderName: 'X-XSRF-TOKEN',
  1095. maxContentLength: -1,
  1096. maxBodyLength: -1,
  1097. validateStatus: function validateStatus(status) {
  1098. return status >= 200 && status < 300;
  1099. },
  1100. headers: {
  1101. common: {
  1102. 'Accept': 'application/json, text/plain, */*'
  1103. }
  1104. }
  1105. };
  1106. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1107. defaults.headers[method] = {};
  1108. });
  1109. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1110. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1111. });
  1112. module.exports = defaults;
  1113. /***/ }),
  1114. /***/ "./lib/env/data.js":
  1115. /*!*************************!*\
  1116. !*** ./lib/env/data.js ***!
  1117. \*************************/
  1118. /*! no static exports found */
  1119. /***/ (function(module, exports) {
  1120. module.exports = {
  1121. "version": "0.26.0"
  1122. };
  1123. /***/ }),
  1124. /***/ "./lib/helpers/bind.js":
  1125. /*!*****************************!*\
  1126. !*** ./lib/helpers/bind.js ***!
  1127. \*****************************/
  1128. /*! no static exports found */
  1129. /***/ (function(module, exports, __webpack_require__) {
  1130. "use strict";
  1131. module.exports = function bind(fn, thisArg) {
  1132. return function wrap() {
  1133. var args = new Array(arguments.length);
  1134. for (var i = 0; i < args.length; i++) {
  1135. args[i] = arguments[i];
  1136. }
  1137. return fn.apply(thisArg, args);
  1138. };
  1139. };
  1140. /***/ }),
  1141. /***/ "./lib/helpers/buildURL.js":
  1142. /*!*********************************!*\
  1143. !*** ./lib/helpers/buildURL.js ***!
  1144. \*********************************/
  1145. /*! no static exports found */
  1146. /***/ (function(module, exports, __webpack_require__) {
  1147. "use strict";
  1148. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1149. function encode(val) {
  1150. return encodeURIComponent(val).
  1151. replace(/%3A/gi, ':').
  1152. replace(/%24/g, '$').
  1153. replace(/%2C/gi, ',').
  1154. replace(/%20/g, '+').
  1155. replace(/%5B/gi, '[').
  1156. replace(/%5D/gi, ']');
  1157. }
  1158. /**
  1159. * Build a URL by appending params to the end
  1160. *
  1161. * @param {string} url The base of the url (e.g., http://www.google.com)
  1162. * @param {object} [params] The params to be appended
  1163. * @returns {string} The formatted url
  1164. */
  1165. module.exports = function buildURL(url, params, paramsSerializer) {
  1166. /*eslint no-param-reassign:0*/
  1167. if (!params) {
  1168. return url;
  1169. }
  1170. var serializedParams;
  1171. if (paramsSerializer) {
  1172. serializedParams = paramsSerializer(params);
  1173. } else if (utils.isURLSearchParams(params)) {
  1174. serializedParams = params.toString();
  1175. } else {
  1176. var parts = [];
  1177. utils.forEach(params, function serialize(val, key) {
  1178. if (val === null || typeof val === 'undefined') {
  1179. return;
  1180. }
  1181. if (utils.isArray(val)) {
  1182. key = key + '[]';
  1183. } else {
  1184. val = [val];
  1185. }
  1186. utils.forEach(val, function parseValue(v) {
  1187. if (utils.isDate(v)) {
  1188. v = v.toISOString();
  1189. } else if (utils.isObject(v)) {
  1190. v = JSON.stringify(v);
  1191. }
  1192. parts.push(encode(key) + '=' + encode(v));
  1193. });
  1194. });
  1195. serializedParams = parts.join('&');
  1196. }
  1197. if (serializedParams) {
  1198. var hashmarkIndex = url.indexOf('#');
  1199. if (hashmarkIndex !== -1) {
  1200. url = url.slice(0, hashmarkIndex);
  1201. }
  1202. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1203. }
  1204. return url;
  1205. };
  1206. /***/ }),
  1207. /***/ "./lib/helpers/combineURLs.js":
  1208. /*!************************************!*\
  1209. !*** ./lib/helpers/combineURLs.js ***!
  1210. \************************************/
  1211. /*! no static exports found */
  1212. /***/ (function(module, exports, __webpack_require__) {
  1213. "use strict";
  1214. /**
  1215. * Creates a new URL by combining the specified URLs
  1216. *
  1217. * @param {string} baseURL The base URL
  1218. * @param {string} relativeURL The relative URL
  1219. * @returns {string} The combined URL
  1220. */
  1221. module.exports = function combineURLs(baseURL, relativeURL) {
  1222. return relativeURL
  1223. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1224. : baseURL;
  1225. };
  1226. /***/ }),
  1227. /***/ "./lib/helpers/cookies.js":
  1228. /*!********************************!*\
  1229. !*** ./lib/helpers/cookies.js ***!
  1230. \********************************/
  1231. /*! no static exports found */
  1232. /***/ (function(module, exports, __webpack_require__) {
  1233. "use strict";
  1234. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1235. module.exports = (
  1236. utils.isStandardBrowserEnv() ?
  1237. // Standard browser envs support document.cookie
  1238. (function standardBrowserEnv() {
  1239. return {
  1240. write: function write(name, value, expires, path, domain, secure) {
  1241. var cookie = [];
  1242. cookie.push(name + '=' + encodeURIComponent(value));
  1243. if (utils.isNumber(expires)) {
  1244. cookie.push('expires=' + new Date(expires).toGMTString());
  1245. }
  1246. if (utils.isString(path)) {
  1247. cookie.push('path=' + path);
  1248. }
  1249. if (utils.isString(domain)) {
  1250. cookie.push('domain=' + domain);
  1251. }
  1252. if (secure === true) {
  1253. cookie.push('secure');
  1254. }
  1255. document.cookie = cookie.join('; ');
  1256. },
  1257. read: function read(name) {
  1258. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1259. return (match ? decodeURIComponent(match[3]) : null);
  1260. },
  1261. remove: function remove(name) {
  1262. this.write(name, '', Date.now() - 86400000);
  1263. }
  1264. };
  1265. })() :
  1266. // Non standard browser env (web workers, react-native) lack needed support.
  1267. (function nonStandardBrowserEnv() {
  1268. return {
  1269. write: function write() {},
  1270. read: function read() { return null; },
  1271. remove: function remove() {}
  1272. };
  1273. })()
  1274. );
  1275. /***/ }),
  1276. /***/ "./lib/helpers/isAbsoluteURL.js":
  1277. /*!**************************************!*\
  1278. !*** ./lib/helpers/isAbsoluteURL.js ***!
  1279. \**************************************/
  1280. /*! no static exports found */
  1281. /***/ (function(module, exports, __webpack_require__) {
  1282. "use strict";
  1283. /**
  1284. * Determines whether the specified URL is absolute
  1285. *
  1286. * @param {string} url The URL to test
  1287. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1288. */
  1289. module.exports = function isAbsoluteURL(url) {
  1290. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1291. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1292. // by any combination of letters, digits, plus, period, or hyphen.
  1293. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1294. };
  1295. /***/ }),
  1296. /***/ "./lib/helpers/isAxiosError.js":
  1297. /*!*************************************!*\
  1298. !*** ./lib/helpers/isAxiosError.js ***!
  1299. \*************************************/
  1300. /*! no static exports found */
  1301. /***/ (function(module, exports, __webpack_require__) {
  1302. "use strict";
  1303. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1304. /**
  1305. * Determines whether the payload is an error thrown by Axios
  1306. *
  1307. * @param {*} payload The value to test
  1308. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1309. */
  1310. module.exports = function isAxiosError(payload) {
  1311. return utils.isObject(payload) && (payload.isAxiosError === true);
  1312. };
  1313. /***/ }),
  1314. /***/ "./lib/helpers/isURLSameOrigin.js":
  1315. /*!****************************************!*\
  1316. !*** ./lib/helpers/isURLSameOrigin.js ***!
  1317. \****************************************/
  1318. /*! no static exports found */
  1319. /***/ (function(module, exports, __webpack_require__) {
  1320. "use strict";
  1321. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1322. module.exports = (
  1323. utils.isStandardBrowserEnv() ?
  1324. // Standard browser envs have full support of the APIs needed to test
  1325. // whether the request URL is of the same origin as current location.
  1326. (function standardBrowserEnv() {
  1327. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1328. var urlParsingNode = document.createElement('a');
  1329. var originURL;
  1330. /**
  1331. * Parse a URL to discover it's components
  1332. *
  1333. * @param {String} url The URL to be parsed
  1334. * @returns {Object}
  1335. */
  1336. function resolveURL(url) {
  1337. var href = url;
  1338. if (msie) {
  1339. // IE needs attribute set twice to normalize properties
  1340. urlParsingNode.setAttribute('href', href);
  1341. href = urlParsingNode.href;
  1342. }
  1343. urlParsingNode.setAttribute('href', href);
  1344. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1345. return {
  1346. href: urlParsingNode.href,
  1347. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1348. host: urlParsingNode.host,
  1349. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1350. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1351. hostname: urlParsingNode.hostname,
  1352. port: urlParsingNode.port,
  1353. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1354. urlParsingNode.pathname :
  1355. '/' + urlParsingNode.pathname
  1356. };
  1357. }
  1358. originURL = resolveURL(window.location.href);
  1359. /**
  1360. * Determine if a URL shares the same origin as the current location
  1361. *
  1362. * @param {String} requestURL The URL to test
  1363. * @returns {boolean} True if URL shares the same origin, otherwise false
  1364. */
  1365. return function isURLSameOrigin(requestURL) {
  1366. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1367. return (parsed.protocol === originURL.protocol &&
  1368. parsed.host === originURL.host);
  1369. };
  1370. })() :
  1371. // Non standard browser envs (web workers, react-native) lack needed support.
  1372. (function nonStandardBrowserEnv() {
  1373. return function isURLSameOrigin() {
  1374. return true;
  1375. };
  1376. })()
  1377. );
  1378. /***/ }),
  1379. /***/ "./lib/helpers/normalizeHeaderName.js":
  1380. /*!********************************************!*\
  1381. !*** ./lib/helpers/normalizeHeaderName.js ***!
  1382. \********************************************/
  1383. /*! no static exports found */
  1384. /***/ (function(module, exports, __webpack_require__) {
  1385. "use strict";
  1386. var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
  1387. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1388. utils.forEach(headers, function processHeader(value, name) {
  1389. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1390. headers[normalizedName] = value;
  1391. delete headers[name];
  1392. }
  1393. });
  1394. };
  1395. /***/ }),
  1396. /***/ "./lib/helpers/parseHeaders.js":
  1397. /*!*************************************!*\
  1398. !*** ./lib/helpers/parseHeaders.js ***!
  1399. \*************************************/
  1400. /*! no static exports found */
  1401. /***/ (function(module, exports, __webpack_require__) {
  1402. "use strict";
  1403. var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
  1404. // Headers whose duplicates are ignored by node
  1405. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1406. var ignoreDuplicateOf = [
  1407. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1408. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1409. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1410. 'referer', 'retry-after', 'user-agent'
  1411. ];
  1412. /**
  1413. * Parse headers into an object
  1414. *
  1415. * ```
  1416. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1417. * Content-Type: application/json
  1418. * Connection: keep-alive
  1419. * Transfer-Encoding: chunked
  1420. * ```
  1421. *
  1422. * @param {String} headers Headers needing to be parsed
  1423. * @returns {Object} Headers parsed into an object
  1424. */
  1425. module.exports = function parseHeaders(headers) {
  1426. var parsed = {};
  1427. var key;
  1428. var val;
  1429. var i;
  1430. if (!headers) { return parsed; }
  1431. utils.forEach(headers.split('\n'), function parser(line) {
  1432. i = line.indexOf(':');
  1433. key = utils.trim(line.substr(0, i)).toLowerCase();
  1434. val = utils.trim(line.substr(i + 1));
  1435. if (key) {
  1436. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1437. return;
  1438. }
  1439. if (key === 'set-cookie') {
  1440. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1441. } else {
  1442. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1443. }
  1444. }
  1445. });
  1446. return parsed;
  1447. };
  1448. /***/ }),
  1449. /***/ "./lib/helpers/spread.js":
  1450. /*!*******************************!*\
  1451. !*** ./lib/helpers/spread.js ***!
  1452. \*******************************/
  1453. /*! no static exports found */
  1454. /***/ (function(module, exports, __webpack_require__) {
  1455. "use strict";
  1456. /**
  1457. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1458. *
  1459. * Common use case would be to use `Function.prototype.apply`.
  1460. *
  1461. * ```js
  1462. * function f(x, y, z) {}
  1463. * var args = [1, 2, 3];
  1464. * f.apply(null, args);
  1465. * ```
  1466. *
  1467. * With `spread` this example can be re-written.
  1468. *
  1469. * ```js
  1470. * spread(function(x, y, z) {})([1, 2, 3]);
  1471. * ```
  1472. *
  1473. * @param {Function} callback
  1474. * @returns {Function}
  1475. */
  1476. module.exports = function spread(callback) {
  1477. return function wrap(arr) {
  1478. return callback.apply(null, arr);
  1479. };
  1480. };
  1481. /***/ }),
  1482. /***/ "./lib/helpers/validator.js":
  1483. /*!**********************************!*\
  1484. !*** ./lib/helpers/validator.js ***!
  1485. \**********************************/
  1486. /*! no static exports found */
  1487. /***/ (function(module, exports, __webpack_require__) {
  1488. "use strict";
  1489. var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
  1490. var validators = {};
  1491. // eslint-disable-next-line func-names
  1492. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1493. validators[type] = function validator(thing) {
  1494. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1495. };
  1496. });
  1497. var deprecatedWarnings = {};
  1498. /**
  1499. * Transitional option validator
  1500. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  1501. * @param {string?} version - deprecated version / removed since version
  1502. * @param {string?} message - some message with additional info
  1503. * @returns {function}
  1504. */
  1505. validators.transitional = function transitional(validator, version, message) {
  1506. function formatMessage(opt, desc) {
  1507. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1508. }
  1509. // eslint-disable-next-line func-names
  1510. return function(value, opt, opts) {
  1511. if (validator === false) {
  1512. throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
  1513. }
  1514. if (version && !deprecatedWarnings[opt]) {
  1515. deprecatedWarnings[opt] = true;
  1516. // eslint-disable-next-line no-console
  1517. console.warn(
  1518. formatMessage(
  1519. opt,
  1520. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1521. )
  1522. );
  1523. }
  1524. return validator ? validator(value, opt, opts) : true;
  1525. };
  1526. };
  1527. /**
  1528. * Assert object's properties type
  1529. * @param {object} options
  1530. * @param {object} schema
  1531. * @param {boolean?} allowUnknown
  1532. */
  1533. function assertOptions(options, schema, allowUnknown) {
  1534. if (typeof options !== 'object') {
  1535. throw new TypeError('options must be an object');
  1536. }
  1537. var keys = Object.keys(options);
  1538. var i = keys.length;
  1539. while (i-- > 0) {
  1540. var opt = keys[i];
  1541. var validator = schema[opt];
  1542. if (validator) {
  1543. var value = options[opt];
  1544. var result = value === undefined || validator(value, opt, options);
  1545. if (result !== true) {
  1546. throw new TypeError('option ' + opt + ' must be ' + result);
  1547. }
  1548. continue;
  1549. }
  1550. if (allowUnknown !== true) {
  1551. throw Error('Unknown option ' + opt);
  1552. }
  1553. }
  1554. }
  1555. module.exports = {
  1556. assertOptions: assertOptions,
  1557. validators: validators
  1558. };
  1559. /***/ }),
  1560. /***/ "./lib/utils.js":
  1561. /*!**********************!*\
  1562. !*** ./lib/utils.js ***!
  1563. \**********************/
  1564. /*! no static exports found */
  1565. /***/ (function(module, exports, __webpack_require__) {
  1566. "use strict";
  1567. var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
  1568. // utils is a library of generic helper functions non-specific to axios
  1569. var toString = Object.prototype.toString;
  1570. /**
  1571. * Determine if a value is an Array
  1572. *
  1573. * @param {Object} val The value to test
  1574. * @returns {boolean} True if value is an Array, otherwise false
  1575. */
  1576. function isArray(val) {
  1577. return Array.isArray(val);
  1578. }
  1579. /**
  1580. * Determine if a value is undefined
  1581. *
  1582. * @param {Object} val The value to test
  1583. * @returns {boolean} True if the value is undefined, otherwise false
  1584. */
  1585. function isUndefined(val) {
  1586. return typeof val === 'undefined';
  1587. }
  1588. /**
  1589. * Determine if a value is a Buffer
  1590. *
  1591. * @param {Object} val The value to test
  1592. * @returns {boolean} True if value is a Buffer, otherwise false
  1593. */
  1594. function isBuffer(val) {
  1595. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1596. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1597. }
  1598. /**
  1599. * Determine if a value is an ArrayBuffer
  1600. *
  1601. * @param {Object} val The value to test
  1602. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1603. */
  1604. function isArrayBuffer(val) {
  1605. return toString.call(val) === '[object ArrayBuffer]';
  1606. }
  1607. /**
  1608. * Determine if a value is a FormData
  1609. *
  1610. * @param {Object} val The value to test
  1611. * @returns {boolean} True if value is an FormData, otherwise false
  1612. */
  1613. function isFormData(val) {
  1614. return toString.call(val) === '[object FormData]';
  1615. }
  1616. /**
  1617. * Determine if a value is a view on an ArrayBuffer
  1618. *
  1619. * @param {Object} val The value to test
  1620. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1621. */
  1622. function isArrayBufferView(val) {
  1623. var result;
  1624. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1625. result = ArrayBuffer.isView(val);
  1626. } else {
  1627. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  1628. }
  1629. return result;
  1630. }
  1631. /**
  1632. * Determine if a value is a String
  1633. *
  1634. * @param {Object} val The value to test
  1635. * @returns {boolean} True if value is a String, otherwise false
  1636. */
  1637. function isString(val) {
  1638. return typeof val === 'string';
  1639. }
  1640. /**
  1641. * Determine if a value is a Number
  1642. *
  1643. * @param {Object} val The value to test
  1644. * @returns {boolean} True if value is a Number, otherwise false
  1645. */
  1646. function isNumber(val) {
  1647. return typeof val === 'number';
  1648. }
  1649. /**
  1650. * Determine if a value is an Object
  1651. *
  1652. * @param {Object} val The value to test
  1653. * @returns {boolean} True if value is an Object, otherwise false
  1654. */
  1655. function isObject(val) {
  1656. return val !== null && typeof val === 'object';
  1657. }
  1658. /**
  1659. * Determine if a value is a plain Object
  1660. *
  1661. * @param {Object} val The value to test
  1662. * @return {boolean} True if value is a plain Object, otherwise false
  1663. */
  1664. function isPlainObject(val) {
  1665. if (toString.call(val) !== '[object Object]') {
  1666. return false;
  1667. }
  1668. var prototype = Object.getPrototypeOf(val);
  1669. return prototype === null || prototype === Object.prototype;
  1670. }
  1671. /**
  1672. * Determine if a value is a Date
  1673. *
  1674. * @param {Object} val The value to test
  1675. * @returns {boolean} True if value is a Date, otherwise false
  1676. */
  1677. function isDate(val) {
  1678. return toString.call(val) === '[object Date]';
  1679. }
  1680. /**
  1681. * Determine if a value is a File
  1682. *
  1683. * @param {Object} val The value to test
  1684. * @returns {boolean} True if value is a File, otherwise false
  1685. */
  1686. function isFile(val) {
  1687. return toString.call(val) === '[object File]';
  1688. }
  1689. /**
  1690. * Determine if a value is a Blob
  1691. *
  1692. * @param {Object} val The value to test
  1693. * @returns {boolean} True if value is a Blob, otherwise false
  1694. */
  1695. function isBlob(val) {
  1696. return toString.call(val) === '[object Blob]';
  1697. }
  1698. /**
  1699. * Determine if a value is a Function
  1700. *
  1701. * @param {Object} val The value to test
  1702. * @returns {boolean} True if value is a Function, otherwise false
  1703. */
  1704. function isFunction(val) {
  1705. return toString.call(val) === '[object Function]';
  1706. }
  1707. /**
  1708. * Determine if a value is a Stream
  1709. *
  1710. * @param {Object} val The value to test
  1711. * @returns {boolean} True if value is a Stream, otherwise false
  1712. */
  1713. function isStream(val) {
  1714. return isObject(val) && isFunction(val.pipe);
  1715. }
  1716. /**
  1717. * Determine if a value is a URLSearchParams object
  1718. *
  1719. * @param {Object} val The value to test
  1720. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1721. */
  1722. function isURLSearchParams(val) {
  1723. return toString.call(val) === '[object URLSearchParams]';
  1724. }
  1725. /**
  1726. * Trim excess whitespace off the beginning and end of a string
  1727. *
  1728. * @param {String} str The String to trim
  1729. * @returns {String} The String freed of excess whitespace
  1730. */
  1731. function trim(str) {
  1732. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  1733. }
  1734. /**
  1735. * Determine if we're running in a standard browser environment
  1736. *
  1737. * This allows axios to run in a web worker, and react-native.
  1738. * Both environments support XMLHttpRequest, but not fully standard globals.
  1739. *
  1740. * web workers:
  1741. * typeof window -> undefined
  1742. * typeof document -> undefined
  1743. *
  1744. * react-native:
  1745. * navigator.product -> 'ReactNative'
  1746. * nativescript
  1747. * navigator.product -> 'NativeScript' or 'NS'
  1748. */
  1749. function isStandardBrowserEnv() {
  1750. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1751. navigator.product === 'NativeScript' ||
  1752. navigator.product === 'NS')) {
  1753. return false;
  1754. }
  1755. return (
  1756. typeof window !== 'undefined' &&
  1757. typeof document !== 'undefined'
  1758. );
  1759. }
  1760. /**
  1761. * Iterate over an Array or an Object invoking a function for each item.
  1762. *
  1763. * If `obj` is an Array callback will be called passing
  1764. * the value, index, and complete array for each item.
  1765. *
  1766. * If 'obj' is an Object callback will be called passing
  1767. * the value, key, and complete object for each property.
  1768. *
  1769. * @param {Object|Array} obj The object to iterate
  1770. * @param {Function} fn The callback to invoke for each item
  1771. */
  1772. function forEach(obj, fn) {
  1773. // Don't bother if no value provided
  1774. if (obj === null || typeof obj === 'undefined') {
  1775. return;
  1776. }
  1777. // Force an array if not already something iterable
  1778. if (typeof obj !== 'object') {
  1779. /*eslint no-param-reassign:0*/
  1780. obj = [obj];
  1781. }
  1782. if (isArray(obj)) {
  1783. // Iterate over array values
  1784. for (var i = 0, l = obj.length; i < l; i++) {
  1785. fn.call(null, obj[i], i, obj);
  1786. }
  1787. } else {
  1788. // Iterate over object keys
  1789. for (var key in obj) {
  1790. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1791. fn.call(null, obj[key], key, obj);
  1792. }
  1793. }
  1794. }
  1795. }
  1796. /**
  1797. * Accepts varargs expecting each argument to be an object, then
  1798. * immutably merges the properties of each object and returns result.
  1799. *
  1800. * When multiple objects contain the same key the later object in
  1801. * the arguments list will take precedence.
  1802. *
  1803. * Example:
  1804. *
  1805. * ```js
  1806. * var result = merge({foo: 123}, {foo: 456});
  1807. * console.log(result.foo); // outputs 456
  1808. * ```
  1809. *
  1810. * @param {Object} obj1 Object to merge
  1811. * @returns {Object} Result of all merge properties
  1812. */
  1813. function merge(/* obj1, obj2, obj3, ... */) {
  1814. var result = {};
  1815. function assignValue(val, key) {
  1816. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1817. result[key] = merge(result[key], val);
  1818. } else if (isPlainObject(val)) {
  1819. result[key] = merge({}, val);
  1820. } else if (isArray(val)) {
  1821. result[key] = val.slice();
  1822. } else {
  1823. result[key] = val;
  1824. }
  1825. }
  1826. for (var i = 0, l = arguments.length; i < l; i++) {
  1827. forEach(arguments[i], assignValue);
  1828. }
  1829. return result;
  1830. }
  1831. /**
  1832. * Extends object a by mutably adding to it the properties of object b.
  1833. *
  1834. * @param {Object} a The object to be extended
  1835. * @param {Object} b The object to copy properties from
  1836. * @param {Object} thisArg The object to bind function to
  1837. * @return {Object} The resulting value of object a
  1838. */
  1839. function extend(a, b, thisArg) {
  1840. forEach(b, function assignValue(val, key) {
  1841. if (thisArg && typeof val === 'function') {
  1842. a[key] = bind(val, thisArg);
  1843. } else {
  1844. a[key] = val;
  1845. }
  1846. });
  1847. return a;
  1848. }
  1849. /**
  1850. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1851. *
  1852. * @param {string} content with BOM
  1853. * @return {string} content value without BOM
  1854. */
  1855. function stripBOM(content) {
  1856. if (content.charCodeAt(0) === 0xFEFF) {
  1857. content = content.slice(1);
  1858. }
  1859. return content;
  1860. }
  1861. module.exports = {
  1862. isArray: isArray,
  1863. isArrayBuffer: isArrayBuffer,
  1864. isBuffer: isBuffer,
  1865. isFormData: isFormData,
  1866. isArrayBufferView: isArrayBufferView,
  1867. isString: isString,
  1868. isNumber: isNumber,
  1869. isObject: isObject,
  1870. isPlainObject: isPlainObject,
  1871. isUndefined: isUndefined,
  1872. isDate: isDate,
  1873. isFile: isFile,
  1874. isBlob: isBlob,
  1875. isFunction: isFunction,
  1876. isStream: isStream,
  1877. isURLSearchParams: isURLSearchParams,
  1878. isStandardBrowserEnv: isStandardBrowserEnv,
  1879. forEach: forEach,
  1880. merge: merge,
  1881. extend: extend,
  1882. trim: trim,
  1883. stripBOM: stripBOM
  1884. };
  1885. /***/ })
  1886. /******/ });
  1887. });
  1888. //# sourceMappingURL=axios.map