axios 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/dist/esm/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.2.2 Copyright (c) 2022 Matt Zabriskie and contributors
2
2
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -280,7 +280,11 @@ function findKey(obj, key) {
280
280
  return null;
281
281
  }
282
282
 
283
- const _global = typeof self === "undefined" ? typeof global === "undefined" ? undefined : global : self;
283
+ const _global = (() => {
284
+ /*eslint no-undef:0*/
285
+ if (typeof globalThis !== "undefined") return globalThis;
286
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
287
+ })();
284
288
 
285
289
  const isContextDefined = (context) => !isUndefined(context) && context !== _global;
286
290
 
@@ -1217,6 +1221,25 @@ const isStandardBrowserEnv = (() => {
1217
1221
  return typeof window !== 'undefined' && typeof document !== 'undefined';
1218
1222
  })();
1219
1223
 
1224
+ /**
1225
+ * Determine if we're running in a standard browser webWorker environment
1226
+ *
1227
+ * Although the `isStandardBrowserEnv` method indicates that
1228
+ * `allows axios to run in a web worker`, the WebWorker will still be
1229
+ * filtered out due to its judgment standard
1230
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1231
+ * This leads to a problem when axios post `FormData` in webWorker
1232
+ */
1233
+ const isStandardBrowserWebWorkerEnv = (() => {
1234
+ return (
1235
+ typeof WorkerGlobalScope !== 'undefined' &&
1236
+ // eslint-disable-next-line no-undef
1237
+ self instanceof WorkerGlobalScope &&
1238
+ typeof self.importScripts === 'function'
1239
+ );
1240
+ })();
1241
+
1242
+
1220
1243
  const platform = {
1221
1244
  isBrowser: true,
1222
1245
  classes: {
@@ -1225,6 +1248,7 @@ const platform = {
1225
1248
  Blob
1226
1249
  },
1227
1250
  isStandardBrowserEnv,
1251
+ isStandardBrowserWebWorkerEnv,
1228
1252
  protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1229
1253
  };
1230
1254
 
@@ -2089,7 +2113,7 @@ function speedometer(samplesCount, min) {
2089
2113
 
2090
2114
  const passed = startedAt && now - startedAt;
2091
2115
 
2092
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2116
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2093
2117
  };
2094
2118
  }
2095
2119
 
@@ -2140,7 +2164,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2140
2164
  }
2141
2165
  }
2142
2166
 
2143
- if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
2167
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2144
2168
  requestHeaders.setContentType(false); // Let the browser set it
2145
2169
  }
2146
2170
 
@@ -2168,7 +2192,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2168
2192
  const responseHeaders = AxiosHeaders$2.from(
2169
2193
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2170
2194
  );
2171
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2195
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2172
2196
  request.responseText : request.response;
2173
2197
  const response = {
2174
2198
  data: responseData,
@@ -2395,7 +2419,7 @@ function throwIfCancellationRequested(config) {
2395
2419
  }
2396
2420
 
2397
2421
  if (config.signal && config.signal.aborted) {
2398
- throw new CanceledError$1();
2422
+ throw new CanceledError$1(null, config);
2399
2423
  }
2400
2424
  }
2401
2425
 
@@ -2466,7 +2490,7 @@ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSO
2466
2490
  *
2467
2491
  * @returns {Object} New object resulting from merging config2 to config1
2468
2492
  */
2469
- function mergeConfig(config1, config2) {
2493
+ function mergeConfig$1(config1, config2) {
2470
2494
  // eslint-disable-next-line no-param-reassign
2471
2495
  config2 = config2 || {};
2472
2496
  const config = {};
@@ -2556,7 +2580,7 @@ function mergeConfig(config1, config2) {
2556
2580
  return config;
2557
2581
  }
2558
2582
 
2559
- const VERSION$1 = "1.2.0";
2583
+ const VERSION$1 = "1.2.2";
2560
2584
 
2561
2585
  const validators$1 = {};
2562
2586
 
@@ -2681,7 +2705,7 @@ class Axios$1 {
2681
2705
  config = configOrUrl || {};
2682
2706
  }
2683
2707
 
2684
- config = mergeConfig(this.defaults, config);
2708
+ config = mergeConfig$1(this.defaults, config);
2685
2709
 
2686
2710
  const {transitional, paramsSerializer, headers} = config;
2687
2711
 
@@ -2791,7 +2815,7 @@ class Axios$1 {
2791
2815
  }
2792
2816
 
2793
2817
  getUri(config) {
2794
- config = mergeConfig(this.defaults, config);
2818
+ config = mergeConfig$1(this.defaults, config);
2795
2819
  const fullPath = buildFullPath(config.baseURL, config.url);
2796
2820
  return buildURL(fullPath, config.params, config.paramsSerializer);
2797
2821
  }
@@ -2801,7 +2825,7 @@ class Axios$1 {
2801
2825
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2802
2826
  /*eslint func-names:0*/
2803
2827
  Axios$1.prototype[method] = function(url, config) {
2804
- return this.request(mergeConfig(config || {}, {
2828
+ return this.request(mergeConfig$1(config || {}, {
2805
2829
  method,
2806
2830
  url,
2807
2831
  data: (config || {}).data
@@ -2814,7 +2838,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2814
2838
 
2815
2839
  function generateHTTPMethod(isForm) {
2816
2840
  return function httpMethod(url, data, config) {
2817
- return this.request(mergeConfig(config || {}, {
2841
+ return this.request(mergeConfig$1(config || {}, {
2818
2842
  method,
2819
2843
  headers: isForm ? {
2820
2844
  'Content-Type': 'multipart/form-data'
@@ -2988,6 +3012,78 @@ function isAxiosError$1(payload) {
2988
3012
  return utils.isObject(payload) && (payload.isAxiosError === true);
2989
3013
  }
2990
3014
 
3015
+ const HttpStatusCode$1 = {
3016
+ Continue: 100,
3017
+ SwitchingProtocols: 101,
3018
+ Processing: 102,
3019
+ EarlyHints: 103,
3020
+ Ok: 200,
3021
+ Created: 201,
3022
+ Accepted: 202,
3023
+ NonAuthoritativeInformation: 203,
3024
+ NoContent: 204,
3025
+ ResetContent: 205,
3026
+ PartialContent: 206,
3027
+ MultiStatus: 207,
3028
+ AlreadyReported: 208,
3029
+ ImUsed: 226,
3030
+ MultipleChoices: 300,
3031
+ MovedPermanently: 301,
3032
+ Found: 302,
3033
+ SeeOther: 303,
3034
+ NotModified: 304,
3035
+ UseProxy: 305,
3036
+ Unused: 306,
3037
+ TemporaryRedirect: 307,
3038
+ PermanentRedirect: 308,
3039
+ BadRequest: 400,
3040
+ Unauthorized: 401,
3041
+ PaymentRequired: 402,
3042
+ Forbidden: 403,
3043
+ NotFound: 404,
3044
+ MethodNotAllowed: 405,
3045
+ NotAcceptable: 406,
3046
+ ProxyAuthenticationRequired: 407,
3047
+ RequestTimeout: 408,
3048
+ Conflict: 409,
3049
+ Gone: 410,
3050
+ LengthRequired: 411,
3051
+ PreconditionFailed: 412,
3052
+ PayloadTooLarge: 413,
3053
+ UriTooLong: 414,
3054
+ UnsupportedMediaType: 415,
3055
+ RangeNotSatisfiable: 416,
3056
+ ExpectationFailed: 417,
3057
+ ImATeapot: 418,
3058
+ MisdirectedRequest: 421,
3059
+ UnprocessableEntity: 422,
3060
+ Locked: 423,
3061
+ FailedDependency: 424,
3062
+ TooEarly: 425,
3063
+ UpgradeRequired: 426,
3064
+ PreconditionRequired: 428,
3065
+ TooManyRequests: 429,
3066
+ RequestHeaderFieldsTooLarge: 431,
3067
+ UnavailableForLegalReasons: 451,
3068
+ InternalServerError: 500,
3069
+ NotImplemented: 501,
3070
+ BadGateway: 502,
3071
+ ServiceUnavailable: 503,
3072
+ GatewayTimeout: 504,
3073
+ HttpVersionNotSupported: 505,
3074
+ VariantAlsoNegotiates: 506,
3075
+ InsufficientStorage: 507,
3076
+ LoopDetected: 508,
3077
+ NotExtended: 510,
3078
+ NetworkAuthenticationRequired: 511,
3079
+ };
3080
+
3081
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
3082
+ HttpStatusCode$1[value] = key;
3083
+ });
3084
+
3085
+ const HttpStatusCode$2 = HttpStatusCode$1;
3086
+
2991
3087
  /**
2992
3088
  * Create an instance of Axios
2993
3089
  *
@@ -3007,7 +3103,7 @@ function createInstance(defaultConfig) {
3007
3103
 
3008
3104
  // Factory for creating new instances
3009
3105
  instance.create = function create(instanceConfig) {
3010
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
3106
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3011
3107
  };
3012
3108
 
3013
3109
  return instance;
@@ -3042,10 +3138,15 @@ axios.spread = spread$1;
3042
3138
  // Expose isAxiosError
3043
3139
  axios.isAxiosError = isAxiosError$1;
3044
3140
 
3141
+ // Expose mergeConfig
3142
+ axios.mergeConfig = mergeConfig$1;
3143
+
3045
3144
  axios.AxiosHeaders = AxiosHeaders$2;
3046
3145
 
3047
3146
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3048
3147
 
3148
+ axios.HttpStatusCode = HttpStatusCode$2;
3149
+
3049
3150
  axios.default = axios;
3050
3151
 
3051
3152
  // this module should only have a default export
@@ -3067,8 +3168,10 @@ const {
3067
3168
  spread,
3068
3169
  toFormData,
3069
3170
  AxiosHeaders,
3070
- formToJSON
3171
+ HttpStatusCode,
3172
+ formToJSON,
3173
+ mergeConfig
3071
3174
  } = axios$1;
3072
3175
 
3073
- export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, spread, toFormData };
3176
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
3074
3177
  //# sourceMappingURL=axios.js.map