axios.js 62 KB

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