12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645 |
- module.exports = (function() {
- var __MODS__ = {};
- var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
- var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
- var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
- var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
- __DEFINE__(1662612701730, function(require, module, exports) {
- module.exports = require('./lib/axios');
- }, function(modId) {var map = {"./lib/axios":1662612701731}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701731, function(require, module, exports) {
- var utils = require('./utils');
- var bind = require('./helpers/bind');
- var Axios = require('./core/Axios');
- var mergeConfig = require('./core/mergeConfig');
- var defaults = require('./defaults');
- /**
- * Create an instance of Axios
- *
- * @param {Object} defaultConfig The default config for the instance
- * @return {Axios} A new instance of Axios
- */
- function createInstance(defaultConfig) {
- var context = new Axios(defaultConfig);
- var instance = bind(Axios.prototype.request, context);
- // Copy axios.prototype to instance
- utils.extend(instance, Axios.prototype, context);
- // Copy context to instance
- utils.extend(instance, context);
- // Factory for creating new instances
- instance.create = function create(instanceConfig) {
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
- };
- return instance;
- }
- // Create the default instance to be exported
- var axios = createInstance(defaults);
- // Expose Axios class to allow class inheritance
- axios.Axios = Axios;
- // Expose Cancel & CancelToken
- axios.CanceledError = require('./cancel/CanceledError');
- axios.CancelToken = require('./cancel/CancelToken');
- axios.isCancel = require('./cancel/isCancel');
- axios.VERSION = require('./env/data').version;
- axios.toFormData = require('./helpers/toFormData');
- // Expose AxiosError class
- axios.AxiosError = require('../lib/core/AxiosError');
- // alias for CanceledError for backward compatibility
- axios.Cancel = axios.CanceledError;
- // Expose all/spread
- axios.all = function all(promises) {
- return Promise.all(promises);
- };
- axios.spread = require('./helpers/spread');
- // Expose isAxiosError
- axios.isAxiosError = require('./helpers/isAxiosError');
- module.exports = axios;
- // Allow use of default import syntax in TypeScript
- module.exports.default = axios;
- }, function(modId) { var map = {"./utils":1662612701732,"./helpers/bind":1662612701733,"./core/Axios":1662612701734,"./core/mergeConfig":1662612701758,"./defaults":1662612701739,"./cancel/CanceledError":1662612701752,"./cancel/CancelToken":1662612701760,"./cancel/isCancel":1662612701757,"./env/data":1662612701755,"./helpers/toFormData":1662612701743,"../lib/core/AxiosError":1662612701741,"./helpers/spread":1662612701761,"./helpers/isAxiosError":1662612701762}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701732, function(require, module, exports) {
- var bind = require('./helpers/bind');
- // utils is a library of generic helper functions non-specific to axios
- var toString = Object.prototype.toString;
- // eslint-disable-next-line func-names
- var kindOf = (function(cache) {
- // eslint-disable-next-line func-names
- return function(thing) {
- var str = toString.call(thing);
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
- };
- })(Object.create(null));
- function kindOfTest(type) {
- type = type.toLowerCase();
- return function isKindOf(thing) {
- return kindOf(thing) === type;
- };
- }
- /**
- * Determine if a value is an Array
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Array, otherwise false
- */
- function isArray(val) {
- return Array.isArray(val);
- }
- /**
- * Determine if a value is undefined
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if the value is undefined, otherwise false
- */
- function isUndefined(val) {
- return typeof val === 'undefined';
- }
- /**
- * Determine if a value is a Buffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Buffer, otherwise false
- */
- function isBuffer(val) {
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
- }
- /**
- * Determine if a value is an ArrayBuffer
- *
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
- */
- var isArrayBuffer = kindOfTest('ArrayBuffer');
- /**
- * Determine if a value is a view on an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
- */
- function isArrayBufferView(val) {
- var result;
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
- result = ArrayBuffer.isView(val);
- } else {
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
- }
- return result;
- }
- /**
- * Determine if a value is a String
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a String, otherwise false
- */
- function isString(val) {
- return typeof val === 'string';
- }
- /**
- * Determine if a value is a Number
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Number, otherwise false
- */
- function isNumber(val) {
- return typeof val === 'number';
- }
- /**
- * Determine if a value is an Object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Object, otherwise false
- */
- function isObject(val) {
- return val !== null && typeof val === 'object';
- }
- /**
- * Determine if a value is a plain Object
- *
- * @param {Object} val The value to test
- * @return {boolean} True if value is a plain Object, otherwise false
- */
- function isPlainObject(val) {
- if (kindOf(val) !== 'object') {
- return false;
- }
- var prototype = Object.getPrototypeOf(val);
- return prototype === null || prototype === Object.prototype;
- }
- /**
- * Determine if a value is a Date
- *
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Date, otherwise false
- */
- var isDate = kindOfTest('Date');
- /**
- * Determine if a value is a File
- *
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a File, otherwise false
- */
- var isFile = kindOfTest('File');
- /**
- * Determine if a value is a Blob
- *
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Blob, otherwise false
- */
- var isBlob = kindOfTest('Blob');
- /**
- * Determine if a value is a FileList
- *
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a File, otherwise false
- */
- var isFileList = kindOfTest('FileList');
- /**
- * Determine if a value is a Function
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Function, otherwise false
- */
- function isFunction(val) {
- return toString.call(val) === '[object Function]';
- }
- /**
- * Determine if a value is a Stream
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Stream, otherwise false
- */
- function isStream(val) {
- return isObject(val) && isFunction(val.pipe);
- }
- /**
- * Determine if a value is a FormData
- *
- * @param {Object} thing The value to test
- * @returns {boolean} True if value is an FormData, otherwise false
- */
- function isFormData(thing) {
- var pattern = '[object FormData]';
- return thing && (
- (typeof FormData === 'function' && thing instanceof FormData) ||
- toString.call(thing) === pattern ||
- (isFunction(thing.toString) && thing.toString() === pattern)
- );
- }
- /**
- * Determine if a value is a URLSearchParams object
- * @function
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
- */
- var isURLSearchParams = kindOfTest('URLSearchParams');
- /**
- * Trim excess whitespace off the beginning and end of a string
- *
- * @param {String} str The String to trim
- * @returns {String} The String freed of excess whitespace
- */
- function trim(str) {
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
- }
- /**
- * Determine if we're running in a standard browser environment
- *
- * This allows axios to run in a web worker, and react-native.
- * Both environments support XMLHttpRequest, but not fully standard globals.
- *
- * web workers:
- * typeof window -> undefined
- * typeof document -> undefined
- *
- * react-native:
- * navigator.product -> 'ReactNative'
- * nativescript
- * navigator.product -> 'NativeScript' or 'NS'
- */
- function isStandardBrowserEnv() {
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
- navigator.product === 'NativeScript' ||
- navigator.product === 'NS')) {
- return false;
- }
- return (
- typeof window !== 'undefined' &&
- typeof document !== 'undefined'
- );
- }
- /**
- * Iterate over an Array or an Object invoking a function for each item.
- *
- * If `obj` is an Array callback will be called passing
- * the value, index, and complete array for each item.
- *
- * If 'obj' is an Object callback will be called passing
- * the value, key, and complete object for each property.
- *
- * @param {Object|Array} obj The object to iterate
- * @param {Function} fn The callback to invoke for each item
- */
- function forEach(obj, fn) {
- // Don't bother if no value provided
- if (obj === null || typeof obj === 'undefined') {
- return;
- }
- // Force an array if not already something iterable
- if (typeof obj !== 'object') {
- /*eslint no-param-reassign:0*/
- obj = [obj];
- }
- if (isArray(obj)) {
- // Iterate over array values
- for (var i = 0, l = obj.length; i < l; i++) {
- fn.call(null, obj[i], i, obj);
- }
- } else {
- // Iterate over object keys
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- fn.call(null, obj[key], key, obj);
- }
- }
- }
- }
- /**
- * Accepts varargs expecting each argument to be an object, then
- * immutably merges the properties of each object and returns result.
- *
- * When multiple objects contain the same key the later object in
- * the arguments list will take precedence.
- *
- * Example:
- *
- * ```js
- * var result = merge({foo: 123}, {foo: 456});
- * console.log(result.foo); // outputs 456
- * ```
- *
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
- function merge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (isPlainObject(result[key]) && isPlainObject(val)) {
- result[key] = merge(result[key], val);
- } else if (isPlainObject(val)) {
- result[key] = merge({}, val);
- } else if (isArray(val)) {
- result[key] = val.slice();
- } else {
- result[key] = val;
- }
- }
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
- }
- /**
- * Extends object a by mutably adding to it the properties of object b.
- *
- * @param {Object} a The object to be extended
- * @param {Object} b The object to copy properties from
- * @param {Object} thisArg The object to bind function to
- * @return {Object} The resulting value of object a
- */
- function extend(a, b, thisArg) {
- forEach(b, function assignValue(val, key) {
- if (thisArg && typeof val === 'function') {
- a[key] = bind(val, thisArg);
- } else {
- a[key] = val;
- }
- });
- return a;
- }
- /**
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
- *
- * @param {string} content with BOM
- * @return {string} content value without BOM
- */
- function stripBOM(content) {
- if (content.charCodeAt(0) === 0xFEFF) {
- content = content.slice(1);
- }
- return content;
- }
- /**
- * Inherit the prototype methods from one constructor into another
- * @param {function} constructor
- * @param {function} superConstructor
- * @param {object} [props]
- * @param {object} [descriptors]
- */
- function inherits(constructor, superConstructor, props, descriptors) {
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
- constructor.prototype.constructor = constructor;
- props && Object.assign(constructor.prototype, props);
- }
- /**
- * Resolve object with deep prototype chain to a flat object
- * @param {Object} sourceObj source object
- * @param {Object} [destObj]
- * @param {Function} [filter]
- * @returns {Object}
- */
- function toFlatObject(sourceObj, destObj, filter) {
- var props;
- var i;
- var prop;
- var merged = {};
- destObj = destObj || {};
- do {
- props = Object.getOwnPropertyNames(sourceObj);
- i = props.length;
- while (i-- > 0) {
- prop = props[i];
- if (!merged[prop]) {
- destObj[prop] = sourceObj[prop];
- merged[prop] = true;
- }
- }
- sourceObj = Object.getPrototypeOf(sourceObj);
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
- return destObj;
- }
- /*
- * determines whether a string ends with the characters of a specified string
- * @param {String} str
- * @param {String} searchString
- * @param {Number} [position= 0]
- * @returns {boolean}
- */
- function endsWith(str, searchString, position) {
- str = String(str);
- if (position === undefined || position > str.length) {
- position = str.length;
- }
- position -= searchString.length;
- var lastIndex = str.indexOf(searchString, position);
- return lastIndex !== -1 && lastIndex === position;
- }
- /**
- * Returns new array from array like object
- * @param {*} [thing]
- * @returns {Array}
- */
- function toArray(thing) {
- if (!thing) return null;
- var i = thing.length;
- if (isUndefined(i)) return null;
- var arr = new Array(i);
- while (i-- > 0) {
- arr[i] = thing[i];
- }
- return arr;
- }
- // eslint-disable-next-line func-names
- var isTypedArray = (function(TypedArray) {
- // eslint-disable-next-line func-names
- return function(thing) {
- return TypedArray && thing instanceof TypedArray;
- };
- })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
- module.exports = {
- isArray: isArray,
- isArrayBuffer: isArrayBuffer,
- isBuffer: isBuffer,
- isFormData: isFormData,
- isArrayBufferView: isArrayBufferView,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject,
- isPlainObject: isPlainObject,
- isUndefined: isUndefined,
- isDate: isDate,
- isFile: isFile,
- isBlob: isBlob,
- isFunction: isFunction,
- isStream: isStream,
- isURLSearchParams: isURLSearchParams,
- isStandardBrowserEnv: isStandardBrowserEnv,
- forEach: forEach,
- merge: merge,
- extend: extend,
- trim: trim,
- stripBOM: stripBOM,
- inherits: inherits,
- toFlatObject: toFlatObject,
- kindOf: kindOf,
- kindOfTest: kindOfTest,
- endsWith: endsWith,
- toArray: toArray,
- isTypedArray: isTypedArray,
- isFileList: isFileList
- };
- }, function(modId) { var map = {"./helpers/bind":1662612701733}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701733, function(require, module, exports) {
- module.exports = function bind(fn, thisArg) {
- return function wrap() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- return fn.apply(thisArg, args);
- };
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701734, function(require, module, exports) {
- var utils = require('./../utils');
- var buildURL = require('../helpers/buildURL');
- var InterceptorManager = require('./InterceptorManager');
- var dispatchRequest = require('./dispatchRequest');
- var mergeConfig = require('./mergeConfig');
- var buildFullPath = require('./buildFullPath');
- var validator = require('../helpers/validator');
- var validators = validator.validators;
- /**
- * Create a new instance of Axios
- *
- * @param {Object} instanceConfig The default config for the instance
- */
- function Axios(instanceConfig) {
- this.defaults = instanceConfig;
- this.interceptors = {
- request: new InterceptorManager(),
- response: new InterceptorManager()
- };
- }
- /**
- * Dispatch a request
- *
- * @param {Object} config The config specific for this request (merged with this.defaults)
- */
- Axios.prototype.request = function request(configOrUrl, config) {
- /*eslint no-param-reassign:0*/
- // Allow for axios('example/url'[, config]) a la fetch API
- if (typeof configOrUrl === 'string') {
- config = config || {};
- config.url = configOrUrl;
- } else {
- config = configOrUrl || {};
- }
- config = mergeConfig(this.defaults, config);
- // Set config.method
- if (config.method) {
- config.method = config.method.toLowerCase();
- } else if (this.defaults.method) {
- config.method = this.defaults.method.toLowerCase();
- } else {
- config.method = 'get';
- }
- var transitional = config.transitional;
- if (transitional !== undefined) {
- validator.assertOptions(transitional, {
- silentJSONParsing: validators.transitional(validators.boolean),
- forcedJSONParsing: validators.transitional(validators.boolean),
- clarifyTimeoutError: validators.transitional(validators.boolean)
- }, false);
- }
- // filter out skipped interceptors
- var requestInterceptorChain = [];
- var synchronousRequestInterceptors = true;
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
- return;
- }
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
- });
- var responseInterceptorChain = [];
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
- });
- var promise;
- if (!synchronousRequestInterceptors) {
- var chain = [dispatchRequest, undefined];
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
- chain = chain.concat(responseInterceptorChain);
- promise = Promise.resolve(config);
- while (chain.length) {
- promise = promise.then(chain.shift(), chain.shift());
- }
- return promise;
- }
- var newConfig = config;
- while (requestInterceptorChain.length) {
- var onFulfilled = requestInterceptorChain.shift();
- var onRejected = requestInterceptorChain.shift();
- try {
- newConfig = onFulfilled(newConfig);
- } catch (error) {
- onRejected(error);
- break;
- }
- }
- try {
- promise = dispatchRequest(newConfig);
- } catch (error) {
- return Promise.reject(error);
- }
- while (responseInterceptorChain.length) {
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
- }
- return promise;
- };
- Axios.prototype.getUri = function getUri(config) {
- config = mergeConfig(this.defaults, config);
- var fullPath = buildFullPath(config.baseURL, config.url);
- return buildURL(fullPath, config.params, config.paramsSerializer);
- };
- // Provide aliases for supported request methods
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function(url, config) {
- return this.request(mergeConfig(config || {}, {
- method: method,
- url: url,
- data: (config || {}).data
- }));
- };
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- /*eslint func-names:0*/
- function generateHTTPMethod(isForm) {
- return function httpMethod(url, data, config) {
- return this.request(mergeConfig(config || {}, {
- method: method,
- headers: isForm ? {
- 'Content-Type': 'multipart/form-data'
- } : {},
- url: url,
- data: data
- }));
- };
- }
- Axios.prototype[method] = generateHTTPMethod();
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
- });
- module.exports = Axios;
- }, function(modId) { var map = {"./../utils":1662612701732,"../helpers/buildURL":1662612701735,"./InterceptorManager":1662612701736,"./dispatchRequest":1662612701737,"./mergeConfig":1662612701758,"./buildFullPath":1662612701747,"../helpers/validator":1662612701759}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701735, function(require, module, exports) {
- var utils = require('./../utils');
- function encode(val) {
- return encodeURIComponent(val).
- replace(/%3A/gi, ':').
- replace(/%24/g, '$').
- replace(/%2C/gi, ',').
- replace(/%20/g, '+').
- replace(/%5B/gi, '[').
- replace(/%5D/gi, ']');
- }
- /**
- * Build a URL by appending params to the end
- *
- * @param {string} url The base of the url (e.g., http://www.google.com)
- * @param {object} [params] The params to be appended
- * @returns {string} The formatted url
- */
- module.exports = function buildURL(url, params, paramsSerializer) {
- /*eslint no-param-reassign:0*/
- if (!params) {
- return url;
- }
- var serializedParams;
- if (paramsSerializer) {
- serializedParams = paramsSerializer(params);
- } else if (utils.isURLSearchParams(params)) {
- serializedParams = params.toString();
- } else {
- var parts = [];
- utils.forEach(params, function serialize(val, key) {
- if (val === null || typeof val === 'undefined') {
- return;
- }
- if (utils.isArray(val)) {
- key = key + '[]';
- } else {
- val = [val];
- }
- utils.forEach(val, function parseValue(v) {
- if (utils.isDate(v)) {
- v = v.toISOString();
- } else if (utils.isObject(v)) {
- v = JSON.stringify(v);
- }
- parts.push(encode(key) + '=' + encode(v));
- });
- });
- serializedParams = parts.join('&');
- }
- if (serializedParams) {
- var hashmarkIndex = url.indexOf('#');
- if (hashmarkIndex !== -1) {
- url = url.slice(0, hashmarkIndex);
- }
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
- }
- return url;
- };
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701736, function(require, module, exports) {
- var utils = require('./../utils');
- function InterceptorManager() {
- this.handlers = [];
- }
- /**
- * Add a new interceptor to the stack
- *
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
- * @param {Function} rejected The function to handle `reject` for a `Promise`
- *
- * @return {Number} An ID used to remove interceptor later
- */
- InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
- this.handlers.push({
- fulfilled: fulfilled,
- rejected: rejected,
- synchronous: options ? options.synchronous : false,
- runWhen: options ? options.runWhen : null
- });
- return this.handlers.length - 1;
- };
- /**
- * Remove an interceptor from the stack
- *
- * @param {Number} id The ID that was returned by `use`
- */
- InterceptorManager.prototype.eject = function eject(id) {
- if (this.handlers[id]) {
- this.handlers[id] = null;
- }
- };
- /**
- * Iterate over all the registered interceptors
- *
- * This method is particularly useful for skipping over any
- * interceptors that may have become `null` calling `eject`.
- *
- * @param {Function} fn The function to call for each interceptor
- */
- InterceptorManager.prototype.forEach = function forEach(fn) {
- utils.forEach(this.handlers, function forEachHandler(h) {
- if (h !== null) {
- fn(h);
- }
- });
- };
- module.exports = InterceptorManager;
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701737, function(require, module, exports) {
- var utils = require('./../utils');
- var transformData = require('./transformData');
- var isCancel = require('../cancel/isCancel');
- var defaults = require('../defaults');
- var CanceledError = require('../cancel/CanceledError');
- /**
- * Throws a `CanceledError` if cancellation has been requested.
- */
- function throwIfCancellationRequested(config) {
- if (config.cancelToken) {
- config.cancelToken.throwIfRequested();
- }
- if (config.signal && config.signal.aborted) {
- throw new CanceledError();
- }
- }
- /**
- * Dispatch a request to the server using the configured adapter.
- *
- * @param {object} config The config that is to be used for the request
- * @returns {Promise} The Promise to be fulfilled
- */
- module.exports = function dispatchRequest(config) {
- throwIfCancellationRequested(config);
- // Ensure headers exist
- config.headers = config.headers || {};
- // Transform request data
- config.data = transformData.call(
- config,
- config.data,
- config.headers,
- config.transformRequest
- );
- // Flatten headers
- config.headers = utils.merge(
- config.headers.common || {},
- config.headers[config.method] || {},
- config.headers
- );
- utils.forEach(
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
- function cleanHeaderConfig(method) {
- delete config.headers[method];
- }
- );
- var adapter = config.adapter || defaults.adapter;
- return adapter(config).then(function onAdapterResolution(response) {
- throwIfCancellationRequested(config);
- // Transform response data
- response.data = transformData.call(
- config,
- response.data,
- response.headers,
- config.transformResponse
- );
- return response;
- }, function onAdapterRejection(reason) {
- if (!isCancel(reason)) {
- throwIfCancellationRequested(config);
- // Transform response data
- if (reason && reason.response) {
- reason.response.data = transformData.call(
- config,
- reason.response.data,
- reason.response.headers,
- config.transformResponse
- );
- }
- }
- return Promise.reject(reason);
- });
- };
- }, function(modId) { var map = {"./../utils":1662612701732,"./transformData":1662612701738,"../cancel/isCancel":1662612701757,"../defaults":1662612701739,"../cancel/CanceledError":1662612701752}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701738, function(require, module, exports) {
- var utils = require('./../utils');
- var defaults = require('../defaults');
- /**
- * Transform the data for a request or a response
- *
- * @param {Object|String} data The data to be transformed
- * @param {Array} headers The headers for the request or response
- * @param {Array|Function} fns A single function or Array of functions
- * @returns {*} The resulting transformed data
- */
- module.exports = function transformData(data, headers, fns) {
- var context = this || defaults;
- /*eslint no-param-reassign:0*/
- utils.forEach(fns, function transform(fn) {
- data = fn.call(context, data, headers);
- });
- return data;
- };
- }, function(modId) { var map = {"./../utils":1662612701732,"../defaults":1662612701739}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701739, function(require, module, exports) {
- var utils = require('../utils');
- var normalizeHeaderName = require('../helpers/normalizeHeaderName');
- var AxiosError = require('../core/AxiosError');
- var transitionalDefaults = require('./transitional');
- var toFormData = require('../helpers/toFormData');
- var DEFAULT_CONTENT_TYPE = {
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
- function setContentTypeIfUnset(headers, value) {
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
- headers['Content-Type'] = value;
- }
- }
- function getDefaultAdapter() {
- var adapter;
- if (typeof XMLHttpRequest !== 'undefined') {
- // For browsers use XHR adapter
- adapter = require('../adapters/xhr');
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
- // For node use HTTP adapter
- adapter = require('../adapters/http');
- }
- return adapter;
- }
- function stringifySafely(rawValue, parser, encoder) {
- if (utils.isString(rawValue)) {
- try {
- (parser || JSON.parse)(rawValue);
- return utils.trim(rawValue);
- } catch (e) {
- if (e.name !== 'SyntaxError') {
- throw e;
- }
- }
- }
- return (encoder || JSON.stringify)(rawValue);
- }
- var defaults = {
- transitional: transitionalDefaults,
- adapter: getDefaultAdapter(),
- transformRequest: [function transformRequest(data, headers) {
- normalizeHeaderName(headers, 'Accept');
- normalizeHeaderName(headers, 'Content-Type');
- if (utils.isFormData(data) ||
- utils.isArrayBuffer(data) ||
- utils.isBuffer(data) ||
- utils.isStream(data) ||
- utils.isFile(data) ||
- utils.isBlob(data)
- ) {
- return data;
- }
- if (utils.isArrayBufferView(data)) {
- return data.buffer;
- }
- if (utils.isURLSearchParams(data)) {
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
- return data.toString();
- }
- var isObjectPayload = utils.isObject(data);
- var contentType = headers && headers['Content-Type'];
- var isFileList;
- if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
- var _FormData = this.env && this.env.FormData;
- return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
- } else if (isObjectPayload || contentType === 'application/json') {
- setContentTypeIfUnset(headers, 'application/json');
- return stringifySafely(data);
- }
- return data;
- }],
- transformResponse: [function transformResponse(data) {
- var transitional = this.transitional || defaults.transitional;
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
- if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
- try {
- return JSON.parse(data);
- } catch (e) {
- if (strictJSONParsing) {
- if (e.name === 'SyntaxError') {
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
- }
- throw e;
- }
- }
- }
- return data;
- }],
- /**
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
- * timeout is not created.
- */
- timeout: 0,
- xsrfCookieName: 'XSRF-TOKEN',
- xsrfHeaderName: 'X-XSRF-TOKEN',
- maxContentLength: -1,
- maxBodyLength: -1,
- env: {
- FormData: require('./env/FormData')
- },
- validateStatus: function validateStatus(status) {
- return status >= 200 && status < 300;
- },
- headers: {
- common: {
- 'Accept': 'application/json, text/plain, */*'
- }
- }
- };
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
- defaults.headers[method] = {};
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
- });
- module.exports = defaults;
- }, function(modId) { var map = {"../utils":1662612701732,"../helpers/normalizeHeaderName":1662612701740,"../core/AxiosError":1662612701741,"./transitional":1662612701742,"../helpers/toFormData":1662612701743,"../adapters/xhr":1662612701744,"../adapters/http":1662612701754,"./env/FormData":1662612701756}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701740, function(require, module, exports) {
- var utils = require('../utils');
- module.exports = function normalizeHeaderName(headers, normalizedName) {
- utils.forEach(headers, function processHeader(value, name) {
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
- headers[normalizedName] = value;
- delete headers[name];
- }
- });
- };
- }, function(modId) { var map = {"../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701741, function(require, module, exports) {
- var utils = require('../utils');
- /**
- * Create an Error with the specified message, config, error code, request and response.
- *
- * @param {string} message The error message.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [config] The config.
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The created error.
- */
- function AxiosError(message, code, config, request, response) {
- Error.call(this);
- this.message = message;
- this.name = 'AxiosError';
- code && (this.code = code);
- config && (this.config = config);
- request && (this.request = request);
- response && (this.response = response);
- }
- utils.inherits(AxiosError, Error, {
- toJSON: function toJSON() {
- return {
- // Standard
- message: this.message,
- name: this.name,
- // Microsoft
- description: this.description,
- number: this.number,
- // Mozilla
- fileName: this.fileName,
- lineNumber: this.lineNumber,
- columnNumber: this.columnNumber,
- stack: this.stack,
- // Axios
- config: this.config,
- code: this.code,
- status: this.response && this.response.status ? this.response.status : null
- };
- }
- });
- var prototype = AxiosError.prototype;
- var descriptors = {};
- [
- 'ERR_BAD_OPTION_VALUE',
- 'ERR_BAD_OPTION',
- 'ECONNABORTED',
- 'ETIMEDOUT',
- 'ERR_NETWORK',
- 'ERR_FR_TOO_MANY_REDIRECTS',
- 'ERR_DEPRECATED',
- 'ERR_BAD_RESPONSE',
- 'ERR_BAD_REQUEST',
- 'ERR_CANCELED'
- // eslint-disable-next-line func-names
- ].forEach(function(code) {
- descriptors[code] = {value: code};
- });
- Object.defineProperties(AxiosError, descriptors);
- Object.defineProperty(prototype, 'isAxiosError', {value: true});
- // eslint-disable-next-line func-names
- AxiosError.from = function(error, code, config, request, response, customProps) {
- var axiosError = Object.create(prototype);
- utils.toFlatObject(error, axiosError, function filter(obj) {
- return obj !== Error.prototype;
- });
- AxiosError.call(axiosError, error.message, code, config, request, response);
- axiosError.name = error.name;
- customProps && Object.assign(axiosError, customProps);
- return axiosError;
- };
- module.exports = AxiosError;
- }, function(modId) { var map = {"../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701742, function(require, module, exports) {
- module.exports = {
- silentJSONParsing: true,
- forcedJSONParsing: true,
- clarifyTimeoutError: false
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701743, function(require, module, exports) {
- var utils = require('../utils');
- /**
- * Convert a data object to FormData
- * @param {Object} obj
- * @param {?Object} [formData]
- * @returns {Object}
- **/
- function toFormData(obj, formData) {
- // eslint-disable-next-line no-param-reassign
- formData = formData || new FormData();
- var stack = [];
- function convertValue(value) {
- if (value === null) return '';
- if (utils.isDate(value)) {
- return value.toISOString();
- }
- if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
- return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
- }
- return value;
- }
- function build(data, parentKey) {
- if (utils.isPlainObject(data) || utils.isArray(data)) {
- if (stack.indexOf(data) !== -1) {
- throw Error('Circular reference detected in ' + parentKey);
- }
- stack.push(data);
- utils.forEach(data, function each(value, key) {
- if (utils.isUndefined(value)) return;
- var fullKey = parentKey ? parentKey + '.' + key : key;
- var arr;
- if (value && !parentKey && typeof value === 'object') {
- if (utils.endsWith(key, '{}')) {
- // eslint-disable-next-line no-param-reassign
- value = JSON.stringify(value);
- } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
- // eslint-disable-next-line func-names
- arr.forEach(function(el) {
- !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
- });
- return;
- }
- }
- build(value, fullKey);
- });
- stack.pop();
- } else {
- formData.append(parentKey, convertValue(data));
- }
- }
- build(obj);
- return formData;
- }
- module.exports = toFormData;
- }, function(modId) { var map = {"../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701744, function(require, module, exports) {
- var utils = require('./../utils');
- var settle = require('./../core/settle');
- var cookies = require('./../helpers/cookies');
- var buildURL = require('./../helpers/buildURL');
- var buildFullPath = require('../core/buildFullPath');
- var parseHeaders = require('./../helpers/parseHeaders');
- var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
- var transitionalDefaults = require('../defaults/transitional');
- var AxiosError = require('../core/AxiosError');
- var CanceledError = require('../cancel/CanceledError');
- var parseProtocol = require('../helpers/parseProtocol');
- module.exports = function xhrAdapter(config) {
- return new Promise(function dispatchXhrRequest(resolve, reject) {
- var requestData = config.data;
- var requestHeaders = config.headers;
- var responseType = config.responseType;
- var onCanceled;
- function done() {
- if (config.cancelToken) {
- config.cancelToken.unsubscribe(onCanceled);
- }
- if (config.signal) {
- config.signal.removeEventListener('abort', onCanceled);
- }
- }
- if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
- delete requestHeaders['Content-Type']; // Let the browser set it
- }
- var request = new XMLHttpRequest();
- // HTTP basic authentication
- if (config.auth) {
- var username = config.auth.username || '';
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
- }
- var fullPath = buildFullPath(config.baseURL, config.url);
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
- // Set the request timeout in MS
- request.timeout = config.timeout;
- function onloadend() {
- if (!request) {
- return;
- }
- // Prepare the response
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
- request.responseText : request.response;
- var response = {
- data: responseData,
- status: request.status,
- statusText: request.statusText,
- headers: responseHeaders,
- config: config,
- request: request
- };
- settle(function _resolve(value) {
- resolve(value);
- done();
- }, function _reject(err) {
- reject(err);
- done();
- }, response);
- // Clean up request
- request = null;
- }
- if ('onloadend' in request) {
- // Use onloadend if available
- request.onloadend = onloadend;
- } else {
- // Listen for ready state to emulate onloadend
- request.onreadystatechange = function handleLoad() {
- if (!request || request.readyState !== 4) {
- return;
- }
- // The request errored out and we didn't get a response, this will be
- // handled by onerror instead
- // With one exception: request that using file: protocol, most browsers
- // will return status as 0 even though it's a successful request
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
- return;
- }
- // readystate handler is calling before onerror or ontimeout handlers,
- // so we should call onloadend on the next 'tick'
- setTimeout(onloadend);
- };
- }
- // Handle browser request cancellation (as opposed to a manual cancellation)
- request.onabort = function handleAbort() {
- if (!request) {
- return;
- }
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
- // Clean up request
- request = null;
- };
- // Handle low level network errors
- request.onerror = function handleError() {
- // Real errors are hidden from us by the browser
- // onerror should only fire if it's a network error
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
- // Clean up request
- request = null;
- };
- // Handle timeout
- request.ontimeout = function handleTimeout() {
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
- var transitional = config.transitional || transitionalDefaults;
- if (config.timeoutErrorMessage) {
- timeoutErrorMessage = config.timeoutErrorMessage;
- }
- reject(new AxiosError(
- timeoutErrorMessage,
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
- config,
- request));
- // Clean up request
- request = null;
- };
- // Add xsrf header
- // This is only done if running in a standard browser environment.
- // Specifically not if we're in a web worker, or react-native.
- if (utils.isStandardBrowserEnv()) {
- // Add xsrf header
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
- cookies.read(config.xsrfCookieName) :
- undefined;
- if (xsrfValue) {
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
- }
- }
- // Add headers to the request
- if ('setRequestHeader' in request) {
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
- // Remove Content-Type if data is undefined
- delete requestHeaders[key];
- } else {
- // Otherwise add header to the request
- request.setRequestHeader(key, val);
- }
- });
- }
- // Add withCredentials to request if needed
- if (!utils.isUndefined(config.withCredentials)) {
- request.withCredentials = !!config.withCredentials;
- }
- // Add responseType to request if needed
- if (responseType && responseType !== 'json') {
- request.responseType = config.responseType;
- }
- // Handle progress if needed
- if (typeof config.onDownloadProgress === 'function') {
- request.addEventListener('progress', config.onDownloadProgress);
- }
- // Not all browsers support upload events
- if (typeof config.onUploadProgress === 'function' && request.upload) {
- request.upload.addEventListener('progress', config.onUploadProgress);
- }
- if (config.cancelToken || config.signal) {
- // Handle cancellation
- // eslint-disable-next-line func-names
- onCanceled = function(cancel) {
- if (!request) {
- return;
- }
- reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
- request.abort();
- request = null;
- };
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
- if (config.signal) {
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
- }
- }
- if (!requestData) {
- requestData = null;
- }
- var protocol = parseProtocol(fullPath);
- if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
- return;
- }
- // Send the request
- request.send(requestData);
- });
- };
- }, function(modId) { var map = {"./../utils":1662612701732,"./../core/settle":1662612701745,"./../helpers/cookies":1662612701746,"./../helpers/buildURL":1662612701735,"../core/buildFullPath":1662612701747,"./../helpers/parseHeaders":1662612701750,"./../helpers/isURLSameOrigin":1662612701751,"../defaults/transitional":1662612701742,"../core/AxiosError":1662612701741,"../cancel/CanceledError":1662612701752,"../helpers/parseProtocol":1662612701753}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701745, function(require, module, exports) {
- var AxiosError = require('./AxiosError');
- /**
- * Resolve or reject a Promise based on response status.
- *
- * @param {Function} resolve A function that resolves the promise.
- * @param {Function} reject A function that rejects the promise.
- * @param {object} response The response.
- */
- module.exports = function settle(resolve, reject, response) {
- var validateStatus = response.config.validateStatus;
- if (!response.status || !validateStatus || validateStatus(response.status)) {
- resolve(response);
- } else {
- reject(new AxiosError(
- 'Request failed with status code ' + response.status,
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
- response.config,
- response.request,
- response
- ));
- }
- };
- }, function(modId) { var map = {"./AxiosError":1662612701741}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701746, function(require, module, exports) {
- var utils = require('./../utils');
- module.exports = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs support document.cookie
- (function standardBrowserEnv() {
- return {
- write: function write(name, value, expires, path, domain, secure) {
- var cookie = [];
- cookie.push(name + '=' + encodeURIComponent(value));
- if (utils.isNumber(expires)) {
- cookie.push('expires=' + new Date(expires).toGMTString());
- }
- if (utils.isString(path)) {
- cookie.push('path=' + path);
- }
- if (utils.isString(domain)) {
- cookie.push('domain=' + domain);
- }
- if (secure === true) {
- cookie.push('secure');
- }
- document.cookie = cookie.join('; ');
- },
- read: function read(name) {
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
- return (match ? decodeURIComponent(match[3]) : null);
- },
- remove: function remove(name) {
- this.write(name, '', Date.now() - 86400000);
- }
- };
- })() :
- // Non standard browser env (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return {
- write: function write() {},
- read: function read() { return null; },
- remove: function remove() {}
- };
- })()
- );
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701747, function(require, module, exports) {
- var isAbsoluteURL = require('../helpers/isAbsoluteURL');
- var combineURLs = require('../helpers/combineURLs');
- /**
- * Creates a new URL by combining the baseURL with the requestedURL,
- * only when the requestedURL is not already an absolute URL.
- * If the requestURL is absolute, this function returns the requestedURL untouched.
- *
- * @param {string} baseURL The base URL
- * @param {string} requestedURL Absolute or relative URL to combine
- * @returns {string} The combined full path
- */
- module.exports = function buildFullPath(baseURL, requestedURL) {
- if (baseURL && !isAbsoluteURL(requestedURL)) {
- return combineURLs(baseURL, requestedURL);
- }
- return requestedURL;
- };
- }, function(modId) { var map = {"../helpers/isAbsoluteURL":1662612701748,"../helpers/combineURLs":1662612701749}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701748, function(require, module, exports) {
- /**
- * Determines whether the specified URL is absolute
- *
- * @param {string} url The URL to test
- * @returns {boolean} True if the specified URL is absolute, otherwise false
- */
- module.exports = function isAbsoluteURL(url) {
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
- // by any combination of letters, digits, plus, period, or hyphen.
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701749, function(require, module, exports) {
- /**
- * Creates a new URL by combining the specified URLs
- *
- * @param {string} baseURL The base URL
- * @param {string} relativeURL The relative URL
- * @returns {string} The combined URL
- */
- module.exports = function combineURLs(baseURL, relativeURL) {
- return relativeURL
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
- : baseURL;
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701750, function(require, module, exports) {
- var utils = require('./../utils');
- // Headers whose duplicates are ignored by node
- // c.f. https://nodejs.org/api/http.html#http_message_headers
- var ignoreDuplicateOf = [
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
- 'referer', 'retry-after', 'user-agent'
- ];
- /**
- * Parse headers into an object
- *
- * ```
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
- * Content-Type: application/json
- * Connection: keep-alive
- * Transfer-Encoding: chunked
- * ```
- *
- * @param {String} headers Headers needing to be parsed
- * @returns {Object} Headers parsed into an object
- */
- module.exports = function parseHeaders(headers) {
- var parsed = {};
- var key;
- var val;
- var i;
- if (!headers) { return parsed; }
- utils.forEach(headers.split('\n'), function parser(line) {
- i = line.indexOf(':');
- key = utils.trim(line.substr(0, i)).toLowerCase();
- val = utils.trim(line.substr(i + 1));
- if (key) {
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
- return;
- }
- if (key === 'set-cookie') {
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
- } else {
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
- }
- }
- });
- return parsed;
- };
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701751, function(require, module, exports) {
- var utils = require('./../utils');
- module.exports = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs have full support of the APIs needed to test
- // whether the request URL is of the same origin as current location.
- (function standardBrowserEnv() {
- var msie = /(msie|trident)/i.test(navigator.userAgent);
- var urlParsingNode = document.createElement('a');
- var originURL;
- /**
- * Parse a URL to discover it's components
- *
- * @param {String} url The URL to be parsed
- * @returns {Object}
- */
- function resolveURL(url) {
- var href = url;
- if (msie) {
- // IE needs attribute set twice to normalize properties
- urlParsingNode.setAttribute('href', href);
- href = urlParsingNode.href;
- }
- urlParsingNode.setAttribute('href', href);
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
- return {
- href: urlParsingNode.href,
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
- host: urlParsingNode.host,
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
- hostname: urlParsingNode.hostname,
- port: urlParsingNode.port,
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
- urlParsingNode.pathname :
- '/' + urlParsingNode.pathname
- };
- }
- originURL = resolveURL(window.location.href);
- /**
- * Determine if a URL shares the same origin as the current location
- *
- * @param {String} requestURL The URL to test
- * @returns {boolean} True if URL shares the same origin, otherwise false
- */
- return function isURLSameOrigin(requestURL) {
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
- return (parsed.protocol === originURL.protocol &&
- parsed.host === originURL.host);
- };
- })() :
- // Non standard browser envs (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return function isURLSameOrigin() {
- return true;
- };
- })()
- );
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701752, function(require, module, exports) {
- var AxiosError = require('../core/AxiosError');
- var utils = require('../utils');
- /**
- * A `CanceledError` is an object that is thrown when an operation is canceled.
- *
- * @class
- * @param {string=} message The message.
- */
- function CanceledError(message) {
- // eslint-disable-next-line no-eq-null,eqeqeq
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
- this.name = 'CanceledError';
- }
- utils.inherits(CanceledError, AxiosError, {
- __CANCEL__: true
- });
- module.exports = CanceledError;
- }, function(modId) { var map = {"../core/AxiosError":1662612701741,"../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701753, function(require, module, exports) {
- module.exports = function parseProtocol(url) {
- var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
- return match && match[1] || '';
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701754, function(require, module, exports) {
- var utils = require('./../utils');
- var settle = require('./../core/settle');
- var buildFullPath = require('../core/buildFullPath');
- var buildURL = require('./../helpers/buildURL');
- var http = require('http');
- var https = require('https');
- var httpFollow = require('follow-redirects').http;
- var httpsFollow = require('follow-redirects').https;
- var url = require('url');
- var zlib = require('zlib');
- var VERSION = require('./../env/data').version;
- var transitionalDefaults = require('../defaults/transitional');
- var AxiosError = require('../core/AxiosError');
- var CanceledError = require('../cancel/CanceledError');
- var isHttps = /https:?/;
- var supportedProtocols = [ 'http:', 'https:', 'file:' ];
- /**
- *
- * @param {http.ClientRequestArgs} options
- * @param {AxiosProxyConfig} proxy
- * @param {string} location
- */
- function setProxy(options, proxy, location) {
- options.hostname = proxy.host;
- options.host = proxy.host;
- options.port = proxy.port;
- options.path = location;
- // Basic proxy authorization
- if (proxy.auth) {
- var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
- }
- // If a proxy is used, any redirects must also pass through the proxy
- options.beforeRedirect = function beforeRedirect(redirection) {
- redirection.headers.host = redirection.host;
- setProxy(redirection, proxy, redirection.href);
- };
- }
- /*eslint consistent-return:0*/
- module.exports = function httpAdapter(config) {
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
- var onCanceled;
- function done() {
- if (config.cancelToken) {
- config.cancelToken.unsubscribe(onCanceled);
- }
- if (config.signal) {
- config.signal.removeEventListener('abort', onCanceled);
- }
- }
- var resolve = function resolve(value) {
- done();
- resolvePromise(value);
- };
- var rejected = false;
- var reject = function reject(value) {
- done();
- rejected = true;
- rejectPromise(value);
- };
- var data = config.data;
- var headers = config.headers;
- var headerNames = {};
- Object.keys(headers).forEach(function storeLowerName(name) {
- headerNames[name.toLowerCase()] = name;
- });
- // Set User-Agent (required by some servers)
- // See https://github.com/axios/axios/issues/69
- if ('user-agent' in headerNames) {
- // User-Agent is specified; handle case where no UA header is desired
- if (!headers[headerNames['user-agent']]) {
- delete headers[headerNames['user-agent']];
- }
- // Otherwise, use specified value
- } else {
- // Only set header if it hasn't been set in config
- headers['User-Agent'] = 'axios/' + VERSION;
- }
- // support for https://www.npmjs.com/package/form-data api
- if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
- Object.assign(headers, data.getHeaders());
- } else if (data && !utils.isStream(data)) {
- if (Buffer.isBuffer(data)) {
- // Nothing to do...
- } else if (utils.isArrayBuffer(data)) {
- data = Buffer.from(new Uint8Array(data));
- } else if (utils.isString(data)) {
- data = Buffer.from(data, 'utf-8');
- } else {
- return reject(new AxiosError(
- 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
- AxiosError.ERR_BAD_REQUEST,
- config
- ));
- }
- if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
- return reject(new AxiosError(
- 'Request body larger than maxBodyLength limit',
- AxiosError.ERR_BAD_REQUEST,
- config
- ));
- }
- // Add Content-Length header if data exists
- if (!headerNames['content-length']) {
- headers['Content-Length'] = data.length;
- }
- }
- // HTTP basic authentication
- var auth = undefined;
- if (config.auth) {
- var username = config.auth.username || '';
- var password = config.auth.password || '';
- auth = username + ':' + password;
- }
- // Parse url
- var fullPath = buildFullPath(config.baseURL, config.url);
- var parsed = url.parse(fullPath);
- var protocol = parsed.protocol || supportedProtocols[0];
- if (supportedProtocols.indexOf(protocol) === -1) {
- return reject(new AxiosError(
- 'Unsupported protocol ' + protocol,
- AxiosError.ERR_BAD_REQUEST,
- config
- ));
- }
- if (!auth && parsed.auth) {
- var urlAuth = parsed.auth.split(':');
- var urlUsername = urlAuth[0] || '';
- var urlPassword = urlAuth[1] || '';
- auth = urlUsername + ':' + urlPassword;
- }
- if (auth && headerNames.authorization) {
- delete headers[headerNames.authorization];
- }
- var isHttpsRequest = isHttps.test(protocol);
- var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
- try {
- buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
- } catch (err) {
- var customErr = new Error(err.message);
- customErr.config = config;
- customErr.url = config.url;
- customErr.exists = true;
- reject(customErr);
- }
- var options = {
- path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
- method: config.method.toUpperCase(),
- headers: headers,
- agent: agent,
- agents: { http: config.httpAgent, https: config.httpsAgent },
- auth: auth
- };
- if (config.socketPath) {
- options.socketPath = config.socketPath;
- } else {
- options.hostname = parsed.hostname;
- options.port = parsed.port;
- }
- var proxy = config.proxy;
- if (!proxy && proxy !== false) {
- var proxyEnv = protocol.slice(0, -1) + '_proxy';
- var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
- if (proxyUrl) {
- var parsedProxyUrl = url.parse(proxyUrl);
- var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
- var shouldProxy = true;
- if (noProxyEnv) {
- var noProxy = noProxyEnv.split(',').map(function trim(s) {
- return s.trim();
- });
- shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
- if (!proxyElement) {
- return false;
- }
- if (proxyElement === '*') {
- return true;
- }
- if (proxyElement[0] === '.' &&
- parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
- return true;
- }
- return parsed.hostname === proxyElement;
- });
- }
- if (shouldProxy) {
- proxy = {
- host: parsedProxyUrl.hostname,
- port: parsedProxyUrl.port,
- protocol: parsedProxyUrl.protocol
- };
- if (parsedProxyUrl.auth) {
- var proxyUrlAuth = parsedProxyUrl.auth.split(':');
- proxy.auth = {
- username: proxyUrlAuth[0],
- password: proxyUrlAuth[1]
- };
- }
- }
- }
- }
- if (proxy) {
- options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
- setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
- }
- var transport;
- var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
- if (config.transport) {
- transport = config.transport;
- } else if (config.maxRedirects === 0) {
- transport = isHttpsProxy ? https : http;
- } else {
- if (config.maxRedirects) {
- options.maxRedirects = config.maxRedirects;
- }
- if (config.beforeRedirect) {
- options.beforeRedirect = config.beforeRedirect;
- }
- transport = isHttpsProxy ? httpsFollow : httpFollow;
- }
- if (config.maxBodyLength > -1) {
- options.maxBodyLength = config.maxBodyLength;
- }
- if (config.insecureHTTPParser) {
- options.insecureHTTPParser = config.insecureHTTPParser;
- }
- // Create the request
- var req = transport.request(options, function handleResponse(res) {
- if (req.aborted) return;
- // uncompress the response body transparently if required
- var stream = res;
- // return the last request in case of redirects
- var lastRequest = res.req || req;
- // if no content, is HEAD request or decompress disabled we should not decompress
- if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
- switch (res.headers['content-encoding']) {
- /*eslint default-case:0*/
- case 'gzip':
- case 'compress':
- case 'deflate':
- // add the unzipper to the body stream processing pipeline
- stream = stream.pipe(zlib.createUnzip());
- // remove the content-encoding in order to not confuse downstream operations
- delete res.headers['content-encoding'];
- break;
- }
- }
- var response = {
- status: res.statusCode,
- statusText: res.statusMessage,
- headers: res.headers,
- config: config,
- request: lastRequest
- };
- if (config.responseType === 'stream') {
- response.data = stream;
- settle(resolve, reject, response);
- } else {
- var responseBuffer = [];
- var totalResponseBytes = 0;
- stream.on('data', function handleStreamData(chunk) {
- responseBuffer.push(chunk);
- totalResponseBytes += chunk.length;
- // make sure the content length is not over the maxContentLength if specified
- if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
- // stream.destoy() emit aborted event before calling reject() on Node.js v16
- rejected = true;
- stream.destroy();
- reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
- AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
- }
- });
- stream.on('aborted', function handlerStreamAborted() {
- if (rejected) {
- return;
- }
- stream.destroy();
- reject(new AxiosError(
- 'maxContentLength size of ' + config.maxContentLength + ' exceeded',
- AxiosError.ERR_BAD_RESPONSE,
- config,
- lastRequest
- ));
- });
- stream.on('error', function handleStreamError(err) {
- if (req.aborted) return;
- reject(AxiosError.from(err, null, config, lastRequest));
- });
- stream.on('end', function handleStreamEnd() {
- try {
- var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
- if (config.responseType !== 'arraybuffer') {
- responseData = responseData.toString(config.responseEncoding);
- if (!config.responseEncoding || config.responseEncoding === 'utf8') {
- responseData = utils.stripBOM(responseData);
- }
- }
- response.data = responseData;
- } catch (err) {
- reject(AxiosError.from(err, null, config, response.request, response));
- }
- settle(resolve, reject, response);
- });
- }
- });
- // Handle errors
- req.on('error', function handleRequestError(err) {
- // @todo remove
- // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
- reject(AxiosError.from(err, null, config, req));
- });
- // set tcp keep alive to prevent drop connection by peer
- req.on('socket', function handleRequestSocket(socket) {
- // default interval of sending ack packet is 1 minute
- socket.setKeepAlive(true, 1000 * 60);
- });
- // Handle request timeout
- if (config.timeout) {
- // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
- var timeout = parseInt(config.timeout, 10);
- if (isNaN(timeout)) {
- reject(new AxiosError(
- 'error trying to parse `config.timeout` to int',
- AxiosError.ERR_BAD_OPTION_VALUE,
- config,
- req
- ));
- return;
- }
- // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
- // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
- // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
- // And then these socket which be hang up will devoring CPU little by little.
- // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
- req.setTimeout(timeout, function handleRequestTimeout() {
- req.abort();
- var transitional = config.transitional || transitionalDefaults;
- reject(new AxiosError(
- 'timeout of ' + timeout + 'ms exceeded',
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
- config,
- req
- ));
- });
- }
- if (config.cancelToken || config.signal) {
- // Handle cancellation
- // eslint-disable-next-line func-names
- onCanceled = function(cancel) {
- if (req.aborted) return;
- req.abort();
- reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
- };
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
- if (config.signal) {
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
- }
- }
- // Send the request
- if (utils.isStream(data)) {
- data.on('error', function handleStreamError(err) {
- reject(AxiosError.from(err, config, null, req));
- }).pipe(req);
- } else {
- req.end(data);
- }
- });
- };
- }, function(modId) { var map = {"./../utils":1662612701732,"./../core/settle":1662612701745,"../core/buildFullPath":1662612701747,"./../helpers/buildURL":1662612701735,"http":1662612701754,"./../env/data":1662612701755,"../defaults/transitional":1662612701742,"../core/AxiosError":1662612701741,"../cancel/CanceledError":1662612701752}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701755, function(require, module, exports) {
- module.exports = {
- "version": "0.27.2"
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701756, function(require, module, exports) {
- // eslint-disable-next-line strict
- module.exports = require('form-data');
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701757, function(require, module, exports) {
- module.exports = function isCancel(value) {
- return !!(value && value.__CANCEL__);
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701758, function(require, module, exports) {
- var utils = require('../utils');
- /**
- * Config-specific merge-function which creates a new config-object
- * by merging two configuration objects together.
- *
- * @param {Object} config1
- * @param {Object} config2
- * @returns {Object} New object resulting from merging config2 to config1
- */
- module.exports = function mergeConfig(config1, config2) {
- // eslint-disable-next-line no-param-reassign
- config2 = config2 || {};
- var config = {};
- function getMergedValue(target, source) {
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
- return utils.merge(target, source);
- } else if (utils.isPlainObject(source)) {
- return utils.merge({}, source);
- } else if (utils.isArray(source)) {
- return source.slice();
- }
- return source;
- }
- // eslint-disable-next-line consistent-return
- function mergeDeepProperties(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(config1[prop], config2[prop]);
- } else if (!utils.isUndefined(config1[prop])) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function valueFromConfig2(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(undefined, config2[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function defaultToConfig2(prop) {
- if (!utils.isUndefined(config2[prop])) {
- return getMergedValue(undefined, config2[prop]);
- } else if (!utils.isUndefined(config1[prop])) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- // eslint-disable-next-line consistent-return
- function mergeDirectKeys(prop) {
- if (prop in config2) {
- return getMergedValue(config1[prop], config2[prop]);
- } else if (prop in config1) {
- return getMergedValue(undefined, config1[prop]);
- }
- }
- var mergeMap = {
- 'url': valueFromConfig2,
- 'method': valueFromConfig2,
- 'data': valueFromConfig2,
- 'baseURL': defaultToConfig2,
- 'transformRequest': defaultToConfig2,
- 'transformResponse': defaultToConfig2,
- 'paramsSerializer': defaultToConfig2,
- 'timeout': defaultToConfig2,
- 'timeoutMessage': defaultToConfig2,
- 'withCredentials': defaultToConfig2,
- 'adapter': defaultToConfig2,
- 'responseType': defaultToConfig2,
- 'xsrfCookieName': defaultToConfig2,
- 'xsrfHeaderName': defaultToConfig2,
- 'onUploadProgress': defaultToConfig2,
- 'onDownloadProgress': defaultToConfig2,
- 'decompress': defaultToConfig2,
- 'maxContentLength': defaultToConfig2,
- 'maxBodyLength': defaultToConfig2,
- 'beforeRedirect': defaultToConfig2,
- 'transport': defaultToConfig2,
- 'httpAgent': defaultToConfig2,
- 'httpsAgent': defaultToConfig2,
- 'cancelToken': defaultToConfig2,
- 'socketPath': defaultToConfig2,
- 'responseEncoding': defaultToConfig2,
- 'validateStatus': mergeDirectKeys
- };
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
- var merge = mergeMap[prop] || mergeDeepProperties;
- var configValue = merge(prop);
- (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
- });
- return config;
- };
- }, function(modId) { var map = {"../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701759, function(require, module, exports) {
- var VERSION = require('../env/data').version;
- var AxiosError = require('../core/AxiosError');
- var validators = {};
- // eslint-disable-next-line func-names
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
- validators[type] = function validator(thing) {
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
- };
- });
- var deprecatedWarnings = {};
- /**
- * Transitional option validator
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
- * @param {string?} version - deprecated version / removed since version
- * @param {string?} message - some message with additional info
- * @returns {function}
- */
- validators.transitional = function transitional(validator, version, message) {
- function formatMessage(opt, desc) {
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
- }
- // eslint-disable-next-line func-names
- return function(value, opt, opts) {
- if (validator === false) {
- throw new AxiosError(
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
- AxiosError.ERR_DEPRECATED
- );
- }
- if (version && !deprecatedWarnings[opt]) {
- deprecatedWarnings[opt] = true;
- // eslint-disable-next-line no-console
- console.warn(
- formatMessage(
- opt,
- ' has been deprecated since v' + version + ' and will be removed in the near future'
- )
- );
- }
- return validator ? validator(value, opt, opts) : true;
- };
- };
- /**
- * Assert object's properties type
- * @param {object} options
- * @param {object} schema
- * @param {boolean?} allowUnknown
- */
- function assertOptions(options, schema, allowUnknown) {
- if (typeof options !== 'object') {
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
- }
- var keys = Object.keys(options);
- var i = keys.length;
- while (i-- > 0) {
- var opt = keys[i];
- var validator = schema[opt];
- if (validator) {
- var value = options[opt];
- var result = value === undefined || validator(value, opt, options);
- if (result !== true) {
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
- }
- continue;
- }
- if (allowUnknown !== true) {
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
- }
- }
- }
- module.exports = {
- assertOptions: assertOptions,
- validators: validators
- };
- }, function(modId) { var map = {"../env/data":1662612701755,"../core/AxiosError":1662612701741}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701760, function(require, module, exports) {
- var CanceledError = require('./CanceledError');
- /**
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
- *
- * @class
- * @param {Function} executor The executor function.
- */
- function CancelToken(executor) {
- if (typeof executor !== 'function') {
- throw new TypeError('executor must be a function.');
- }
- var resolvePromise;
- this.promise = new Promise(function promiseExecutor(resolve) {
- resolvePromise = resolve;
- });
- var token = this;
- // eslint-disable-next-line func-names
- this.promise.then(function(cancel) {
- if (!token._listeners) return;
- var i;
- var l = token._listeners.length;
- for (i = 0; i < l; i++) {
- token._listeners[i](cancel);
- }
- token._listeners = null;
- });
- // eslint-disable-next-line func-names
- this.promise.then = function(onfulfilled) {
- var _resolve;
- // eslint-disable-next-line func-names
- var promise = new Promise(function(resolve) {
- token.subscribe(resolve);
- _resolve = resolve;
- }).then(onfulfilled);
- promise.cancel = function reject() {
- token.unsubscribe(_resolve);
- };
- return promise;
- };
- executor(function cancel(message) {
- if (token.reason) {
- // Cancellation has already been requested
- return;
- }
- token.reason = new CanceledError(message);
- resolvePromise(token.reason);
- });
- }
- /**
- * Throws a `CanceledError` if cancellation has been requested.
- */
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
- if (this.reason) {
- throw this.reason;
- }
- };
- /**
- * Subscribe to the cancel signal
- */
- CancelToken.prototype.subscribe = function subscribe(listener) {
- if (this.reason) {
- listener(this.reason);
- return;
- }
- if (this._listeners) {
- this._listeners.push(listener);
- } else {
- this._listeners = [listener];
- }
- };
- /**
- * Unsubscribe from the cancel signal
- */
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
- if (!this._listeners) {
- return;
- }
- var index = this._listeners.indexOf(listener);
- if (index !== -1) {
- this._listeners.splice(index, 1);
- }
- };
- /**
- * Returns an object that contains a new `CancelToken` and a function that, when called,
- * cancels the `CancelToken`.
- */
- CancelToken.source = function source() {
- var cancel;
- var token = new CancelToken(function executor(c) {
- cancel = c;
- });
- return {
- token: token,
- cancel: cancel
- };
- };
- module.exports = CancelToken;
- }, function(modId) { var map = {"./CanceledError":1662612701752}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701761, function(require, module, exports) {
- /**
- * Syntactic sugar for invoking a function and expanding an array for arguments.
- *
- * Common use case would be to use `Function.prototype.apply`.
- *
- * ```js
- * function f(x, y, z) {}
- * var args = [1, 2, 3];
- * f.apply(null, args);
- * ```
- *
- * With `spread` this example can be re-written.
- *
- * ```js
- * spread(function(x, y, z) {})([1, 2, 3]);
- * ```
- *
- * @param {Function} callback
- * @returns {Function}
- */
- module.exports = function spread(callback) {
- return function wrap(arr) {
- return callback.apply(null, arr);
- };
- };
- }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
- __DEFINE__(1662612701762, function(require, module, exports) {
- var utils = require('./../utils');
- /**
- * Determines whether the payload is an error thrown by Axios
- *
- * @param {*} payload The value to test
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
- */
- module.exports = function isAxiosError(payload) {
- return utils.isObject(payload) && (payload.isAxiosError === true);
- };
- }, function(modId) { var map = {"./../utils":1662612701732}; return __REQUIRE__(map[modId], modId); })
- return __REQUIRE__(1662612701730);
- })()
- //miniprogram-npm-outsideDeps=["https","follow-redirects","url","zlib","form-data"]
- //# sourceMappingURL=index.js.map
|