axios 1.1.3 → 1.3.3

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.

Files changed (47) hide show
  1. package/CHANGELOG.md +298 -75
  2. package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
  3. package/README.md +61 -25
  4. package/dist/axios.js +886 -582
  5. package/dist/axios.js.map +1 -1
  6. package/dist/axios.min.js +1 -1
  7. package/dist/axios.min.js.map +1 -1
  8. package/dist/browser/axios.cjs +3189 -0
  9. package/dist/browser/axios.cjs.map +1 -0
  10. package/dist/esm/axios.js +886 -625
  11. package/dist/esm/axios.js.map +1 -1
  12. package/dist/esm/axios.min.js +1 -1
  13. package/dist/esm/axios.min.js.map +1 -1
  14. package/dist/node/axios.cjs +972 -554
  15. package/dist/node/axios.cjs.map +1 -1
  16. package/index.d.cts +528 -0
  17. package/index.d.ts +116 -56
  18. package/index.js +12 -3
  19. package/lib/adapters/adapters.js +59 -0
  20. package/lib/adapters/http.js +87 -34
  21. package/lib/adapters/xhr.js +7 -4
  22. package/lib/axios.js +13 -3
  23. package/lib/core/Axios.js +10 -8
  24. package/lib/core/AxiosError.js +1 -1
  25. package/lib/core/AxiosHeaders.js +102 -80
  26. package/lib/core/dispatchRequest.js +7 -2
  27. package/lib/core/mergeConfig.js +50 -46
  28. package/lib/defaults/index.js +2 -21
  29. package/lib/env/classes/FormData.js +2 -2
  30. package/lib/env/data.js +1 -1
  31. package/lib/helpers/HttpStatusCode.js +71 -0
  32. package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
  33. package/lib/helpers/formDataToStream.js +111 -0
  34. package/lib/helpers/readBlob.js +15 -0
  35. package/lib/helpers/speedometer.js +1 -1
  36. package/lib/helpers/toFormData.js +5 -15
  37. package/lib/platform/browser/classes/FormData.js +1 -1
  38. package/lib/platform/browser/index.js +20 -0
  39. package/lib/utils.js +107 -9
  40. package/package.json +86 -14
  41. package/bin/ssl_hotfix.js +0 -22
  42. package/gulpfile.js +0 -88
  43. package/karma.conf.cjs +0 -250
  44. package/lib/adapters/index.js +0 -33
  45. package/rollup.config.js +0 -90
  46. package/tsconfig.json +0 -14
  47. package/tslint.json +0 -6
package/lib/axios.js CHANGED
@@ -14,6 +14,8 @@ import toFormData from './helpers/toFormData.js';
14
14
  import AxiosError from './core/AxiosError.js';
15
15
  import spread from './helpers/spread.js';
16
16
  import isAxiosError from './helpers/isAxiosError.js';
17
+ import AxiosHeaders from "./core/AxiosHeaders.js";
18
+ import HttpStatusCode from './helpers/HttpStatusCode.js';
17
19
 
18
20
  /**
19
21
  * Create an instance of Axios
@@ -69,8 +71,16 @@ axios.spread = spread;
69
71
  // Expose isAxiosError
70
72
  axios.isAxiosError = isAxiosError;
71
73
 
72
- axios.formToJSON = thing => {
73
- return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
74
- };
74
+ // Expose mergeConfig
75
+ axios.mergeConfig = mergeConfig;
76
+
77
+ axios.AxiosHeaders = AxiosHeaders;
78
+
79
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
80
+
81
+ axios.HttpStatusCode = HttpStatusCode;
82
+
83
+ axios.default = axios;
75
84
 
85
+ // this module should only have a default export
76
86
  export default axios
package/lib/core/Axios.js CHANGED
@@ -47,7 +47,7 @@ class Axios {
47
47
 
48
48
  config = mergeConfig(this.defaults, config);
49
49
 
50
- const {transitional, paramsSerializer} = config;
50
+ const {transitional, paramsSerializer, headers} = config;
51
51
 
52
52
  if (transitional !== undefined) {
53
53
  validator.assertOptions(transitional, {
@@ -67,20 +67,22 @@ class Axios {
67
67
  // Set config.method
68
68
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
69
69
 
70
+ let contextHeaders;
71
+
70
72
  // Flatten headers
71
- const defaultHeaders = config.headers && utils.merge(
72
- config.headers.common,
73
- config.headers[config.method]
73
+ contextHeaders = headers && utils.merge(
74
+ headers.common,
75
+ headers[config.method]
74
76
  );
75
77
 
76
- defaultHeaders && utils.forEach(
78
+ contextHeaders && utils.forEach(
77
79
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
78
- function cleanHeaderConfig(method) {
79
- delete config.headers[method];
80
+ (method) => {
81
+ delete headers[method];
80
82
  }
81
83
  );
82
84
 
83
- config.headers = new AxiosHeaders(config.headers, defaultHeaders);
85
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
84
86
 
85
87
  // filter out skipped interceptors
86
88
  const requestInterceptorChain = [];
@@ -45,7 +45,7 @@ utils.inherits(AxiosError, Error, {
45
45
  columnNumber: this.columnNumber,
46
46
  stack: this.stack,
47
47
  // Axios
48
- config: this.config,
48
+ config: utils.toJSONObject(this.config),
49
49
  code: this.code,
50
50
  status: this.response && this.response.status ? this.response.status : null
51
51
  };
@@ -4,7 +4,6 @@ import utils from '../utils.js';
4
4
  import parseHeaders from '../helpers/parseHeaders.js';
5
5
 
6
6
  const $internals = Symbol('internals');
7
- const $defaults = Symbol('defaults');
8
7
 
9
8
  function normalizeHeader(header) {
10
9
  return header && String(header).trim().toLowerCase();
@@ -30,11 +29,19 @@ function parseTokens(str) {
30
29
  return tokens;
31
30
  }
32
31
 
33
- function matchHeaderValue(context, value, header, filter) {
32
+ function isValidHeaderName(str) {
33
+ return /^[-_a-zA-Z]+$/.test(str.trim());
34
+ }
35
+
36
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
34
37
  if (utils.isFunction(filter)) {
35
38
  return filter.call(this, value, header);
36
39
  }
37
40
 
41
+ if (isHeaderNameFilter) {
42
+ value = header;
43
+ }
44
+
38
45
  if (!utils.isString(value)) return;
39
46
 
40
47
  if (utils.isString(filter)) {
@@ -66,27 +73,12 @@ function buildAccessors(obj, header) {
66
73
  });
67
74
  }
68
75
 
69
- function findKey(obj, key) {
70
- key = key.toLowerCase();
71
- const keys = Object.keys(obj);
72
- let i = keys.length;
73
- let _key;
74
- while (i-- > 0) {
75
- _key = keys[i];
76
- if (key === _key.toLowerCase()) {
77
- return _key;
78
- }
76
+ class AxiosHeaders {
77
+ constructor(headers) {
78
+ headers && this.set(headers);
79
79
  }
80
- return null;
81
- }
82
80
 
83
- function AxiosHeaders(headers, defaults) {
84
- headers && this.set(headers);
85
- this[$defaults] = defaults || null;
86
- }
87
-
88
- Object.assign(AxiosHeaders.prototype, {
89
- set: function(header, valueOrRewrite, rewrite) {
81
+ set(header, valueOrRewrite, rewrite) {
90
82
  const self = this;
91
83
 
92
84
  function setHeader(_value, _header, _rewrite) {
@@ -96,69 +88,70 @@ Object.assign(AxiosHeaders.prototype, {
96
88
  throw new Error('header name must be a non-empty string');
97
89
  }
98
90
 
99
- const key = findKey(self, lHeader);
91
+ const key = utils.findKey(self, lHeader);
100
92
 
101
- if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
102
- return;
93
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
94
+ self[key || _header] = normalizeValue(_value);
103
95
  }
104
-
105
- self[key || _header] = normalizeValue(_value);
106
96
  }
107
97
 
108
- if (utils.isPlainObject(header)) {
109
- utils.forEach(header, (_value, _header) => {
110
- setHeader(_value, _header, valueOrRewrite);
111
- });
98
+ const setHeaders = (headers, _rewrite) =>
99
+ utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
100
+
101
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
102
+ setHeaders(header, valueOrRewrite)
103
+ } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
104
+ setHeaders(parseHeaders(header), valueOrRewrite);
112
105
  } else {
113
- setHeader(valueOrRewrite, header, rewrite);
106
+ header != null && setHeader(valueOrRewrite, header, rewrite);
114
107
  }
115
108
 
116
109
  return this;
117
- },
110
+ }
118
111
 
119
- get: function(header, parser) {
112
+ get(header, parser) {
120
113
  header = normalizeHeader(header);
121
114
 
122
- if (!header) return undefined;
115
+ if (header) {
116
+ const key = utils.findKey(this, header);
123
117
 
124
- const key = findKey(this, header);
118
+ if (key) {
119
+ const value = this[key];
125
120
 
126
- if (key) {
127
- const value = this[key];
121
+ if (!parser) {
122
+ return value;
123
+ }
128
124
 
129
- if (!parser) {
130
- return value;
131
- }
125
+ if (parser === true) {
126
+ return parseTokens(value);
127
+ }
132
128
 
133
- if (parser === true) {
134
- return parseTokens(value);
135
- }
129
+ if (utils.isFunction(parser)) {
130
+ return parser.call(this, value, key);
131
+ }
136
132
 
137
- if (utils.isFunction(parser)) {
138
- return parser.call(this, value, key);
139
- }
133
+ if (utils.isRegExp(parser)) {
134
+ return parser.exec(value);
135
+ }
140
136
 
141
- if (utils.isRegExp(parser)) {
142
- return parser.exec(value);
137
+ throw new TypeError('parser must be boolean|regexp|function');
143
138
  }
144
-
145
- throw new TypeError('parser must be boolean|regexp|function');
146
139
  }
147
- },
140
+ }
148
141
 
149
- has: function(header, matcher) {
142
+ has(header, matcher) {
150
143
  header = normalizeHeader(header);
151
144
 
152
145
  if (header) {
153
- const key = findKey(this, header);
146
+ const key = utils.findKey(this, header);
154
147
 
155
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
148
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
156
149
  }
157
150
 
158
151
  return false;
159
- },
152
+ }
160
153
 
161
- delete: function(header, matcher) {
154
+ delete(header, matcher) {
162
155
  const self = this;
163
156
  let deleted = false;
164
157
 
@@ -166,7 +159,7 @@ Object.assign(AxiosHeaders.prototype, {
166
159
  _header = normalizeHeader(_header);
167
160
 
168
161
  if (_header) {
169
- const key = findKey(self, _header);
162
+ const key = utils.findKey(self, _header);
170
163
 
171
164
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
172
165
  delete self[key];
@@ -183,18 +176,30 @@ Object.assign(AxiosHeaders.prototype, {
183
176
  }
184
177
 
185
178
  return deleted;
186
- },
179
+ }
187
180
 
188
- clear: function() {
189
- return Object.keys(this).forEach(this.delete.bind(this));
190
- },
181
+ clear(matcher) {
182
+ const keys = Object.keys(this);
183
+ let i = keys.length;
184
+ let deleted = false;
185
+
186
+ while (i--) {
187
+ const key = keys[i];
188
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
189
+ delete this[key];
190
+ deleted = true;
191
+ }
192
+ }
193
+
194
+ return deleted;
195
+ }
191
196
 
192
- normalize: function(format) {
197
+ normalize(format) {
193
198
  const self = this;
194
199
  const headers = {};
195
200
 
196
201
  utils.forEach(this, (value, header) => {
197
- const key = findKey(headers, header);
202
+ const key = utils.findKey(headers, header);
198
203
 
199
204
  if (key) {
200
205
  self[key] = normalizeValue(value);
@@ -214,30 +219,47 @@ Object.assign(AxiosHeaders.prototype, {
214
219
  });
215
220
 
216
221
  return this;
217
- },
222
+ }
223
+
224
+ concat(...targets) {
225
+ return this.constructor.concat(this, ...targets);
226
+ }
218
227
 
219
- toJSON: function(asStrings) {
228
+ toJSON(asStrings) {
220
229
  const obj = Object.create(null);
221
230
 
222
- utils.forEach(Object.assign({}, this[$defaults] || null, this),
223
- (value, header) => {
224
- if (value == null || value === false) return;
225
- obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
226
- });
231
+ utils.forEach(this, (value, header) => {
232
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
233
+ });
227
234
 
228
235
  return obj;
229
236
  }
230
- });
231
237
 
232
- Object.assign(AxiosHeaders, {
233
- from: function(thing) {
234
- if (utils.isString(thing)) {
235
- return new this(parseHeaders(thing));
236
- }
238
+ [Symbol.iterator]() {
239
+ return Object.entries(this.toJSON())[Symbol.iterator]();
240
+ }
241
+
242
+ toString() {
243
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
244
+ }
245
+
246
+ get [Symbol.toStringTag]() {
247
+ return 'AxiosHeaders';
248
+ }
249
+
250
+ static from(thing) {
237
251
  return thing instanceof this ? thing : new this(thing);
238
- },
252
+ }
253
+
254
+ static concat(first, ...targets) {
255
+ const computed = new this(first);
256
+
257
+ targets.forEach((target) => computed.set(target));
239
258
 
240
- accessor: function(header) {
259
+ return computed;
260
+ }
261
+
262
+ static accessor(header) {
241
263
  const internals = this[$internals] = (this[$internals] = {
242
264
  accessors: {}
243
265
  });
@@ -258,9 +280,9 @@ Object.assign(AxiosHeaders, {
258
280
 
259
281
  return this;
260
282
  }
261
- });
283
+ }
262
284
 
263
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
285
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
264
286
 
265
287
  utils.freezeMethods(AxiosHeaders.prototype);
266
288
  utils.freezeMethods(AxiosHeaders);
@@ -5,6 +5,7 @@ import isCancel from '../cancel/isCancel.js';
5
5
  import defaults from '../defaults/index.js';
6
6
  import CanceledError from '../cancel/CanceledError.js';
7
7
  import AxiosHeaders from '../core/AxiosHeaders.js';
8
+ import adapters from "../adapters/adapters.js";
8
9
 
9
10
  /**
10
11
  * Throws a `CanceledError` if cancellation has been requested.
@@ -19,7 +20,7 @@ function throwIfCancellationRequested(config) {
19
20
  }
20
21
 
21
22
  if (config.signal && config.signal.aborted) {
22
- throw new CanceledError();
23
+ throw new CanceledError(null, config);
23
24
  }
24
25
  }
25
26
 
@@ -41,7 +42,11 @@ export default function dispatchRequest(config) {
41
42
  config.transformRequest
42
43
  );
43
44
 
44
- const adapter = config.adapter || defaults.adapter;
45
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
46
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
47
+ }
48
+
49
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
45
50
 
46
51
  return adapter(config).then(function onAdapterResolution(response) {
47
52
  throwIfCancellationRequested(config);
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  import utils from '../utils.js';
4
+ import AxiosHeaders from "./AxiosHeaders.js";
5
+
6
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing;
4
7
 
5
8
  /**
6
9
  * Config-specific merge-function which creates a new config-object
@@ -16,9 +19,9 @@ export default function mergeConfig(config1, config2) {
16
19
  config2 = config2 || {};
17
20
  const config = {};
18
21
 
19
- function getMergedValue(target, source) {
22
+ function getMergedValue(target, source, caseless) {
20
23
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
21
- return utils.merge(target, source);
24
+ return utils.merge.call({caseless}, target, source);
22
25
  } else if (utils.isPlainObject(source)) {
23
26
  return utils.merge({}, source);
24
27
  } else if (utils.isArray(source)) {
@@ -28,72 +31,73 @@ export default function mergeConfig(config1, config2) {
28
31
  }
29
32
 
30
33
  // eslint-disable-next-line consistent-return
31
- function mergeDeepProperties(prop) {
32
- if (!utils.isUndefined(config2[prop])) {
33
- return getMergedValue(config1[prop], config2[prop]);
34
- } else if (!utils.isUndefined(config1[prop])) {
35
- return getMergedValue(undefined, config1[prop]);
34
+ function mergeDeepProperties(a, b, caseless) {
35
+ if (!utils.isUndefined(b)) {
36
+ return getMergedValue(a, b, caseless);
37
+ } else if (!utils.isUndefined(a)) {
38
+ return getMergedValue(undefined, a, caseless);
36
39
  }
37
40
  }
38
41
 
39
42
  // eslint-disable-next-line consistent-return
40
- function valueFromConfig2(prop) {
41
- if (!utils.isUndefined(config2[prop])) {
42
- return getMergedValue(undefined, config2[prop]);
43
+ function valueFromConfig2(a, b) {
44
+ if (!utils.isUndefined(b)) {
45
+ return getMergedValue(undefined, b);
43
46
  }
44
47
  }
45
48
 
46
49
  // eslint-disable-next-line consistent-return
47
- function defaultToConfig2(prop) {
48
- if (!utils.isUndefined(config2[prop])) {
49
- return getMergedValue(undefined, config2[prop]);
50
- } else if (!utils.isUndefined(config1[prop])) {
51
- return getMergedValue(undefined, config1[prop]);
50
+ function defaultToConfig2(a, b) {
51
+ if (!utils.isUndefined(b)) {
52
+ return getMergedValue(undefined, b);
53
+ } else if (!utils.isUndefined(a)) {
54
+ return getMergedValue(undefined, a);
52
55
  }
53
56
  }
54
57
 
55
58
  // eslint-disable-next-line consistent-return
56
- function mergeDirectKeys(prop) {
59
+ function mergeDirectKeys(a, b, prop) {
57
60
  if (prop in config2) {
58
- return getMergedValue(config1[prop], config2[prop]);
61
+ return getMergedValue(a, b);
59
62
  } else if (prop in config1) {
60
- return getMergedValue(undefined, config1[prop]);
63
+ return getMergedValue(undefined, a);
61
64
  }
62
65
  }
63
66
 
64
67
  const mergeMap = {
65
- 'url': valueFromConfig2,
66
- 'method': valueFromConfig2,
67
- 'data': valueFromConfig2,
68
- 'baseURL': defaultToConfig2,
69
- 'transformRequest': defaultToConfig2,
70
- 'transformResponse': defaultToConfig2,
71
- 'paramsSerializer': defaultToConfig2,
72
- 'timeout': defaultToConfig2,
73
- 'timeoutMessage': defaultToConfig2,
74
- 'withCredentials': defaultToConfig2,
75
- 'adapter': defaultToConfig2,
76
- 'responseType': defaultToConfig2,
77
- 'xsrfCookieName': defaultToConfig2,
78
- 'xsrfHeaderName': defaultToConfig2,
79
- 'onUploadProgress': defaultToConfig2,
80
- 'onDownloadProgress': defaultToConfig2,
81
- 'decompress': defaultToConfig2,
82
- 'maxContentLength': defaultToConfig2,
83
- 'maxBodyLength': defaultToConfig2,
84
- 'beforeRedirect': defaultToConfig2,
85
- 'transport': defaultToConfig2,
86
- 'httpAgent': defaultToConfig2,
87
- 'httpsAgent': defaultToConfig2,
88
- 'cancelToken': defaultToConfig2,
89
- 'socketPath': defaultToConfig2,
90
- 'responseEncoding': defaultToConfig2,
91
- 'validateStatus': mergeDirectKeys
68
+ url: valueFromConfig2,
69
+ method: valueFromConfig2,
70
+ data: valueFromConfig2,
71
+ baseURL: defaultToConfig2,
72
+ transformRequest: defaultToConfig2,
73
+ transformResponse: defaultToConfig2,
74
+ paramsSerializer: defaultToConfig2,
75
+ timeout: defaultToConfig2,
76
+ timeoutMessage: defaultToConfig2,
77
+ withCredentials: defaultToConfig2,
78
+ adapter: defaultToConfig2,
79
+ responseType: defaultToConfig2,
80
+ xsrfCookieName: defaultToConfig2,
81
+ xsrfHeaderName: defaultToConfig2,
82
+ onUploadProgress: defaultToConfig2,
83
+ onDownloadProgress: defaultToConfig2,
84
+ decompress: defaultToConfig2,
85
+ maxContentLength: defaultToConfig2,
86
+ maxBodyLength: defaultToConfig2,
87
+ beforeRedirect: defaultToConfig2,
88
+ transport: defaultToConfig2,
89
+ httpAgent: defaultToConfig2,
90
+ httpsAgent: defaultToConfig2,
91
+ cancelToken: defaultToConfig2,
92
+ socketPath: defaultToConfig2,
93
+ responseEncoding: defaultToConfig2,
94
+ validateStatus: mergeDirectKeys,
95
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
92
96
  };
93
97
 
94
98
  utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
95
99
  const merge = mergeMap[prop] || mergeDeepProperties;
96
- const configValue = merge(prop);
100
+ const configValue = merge(config1[prop], config2[prop], prop);
97
101
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
98
102
  });
99
103
 
@@ -7,30 +7,11 @@ import toFormData from '../helpers/toFormData.js';
7
7
  import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
8
8
  import platform from '../platform/index.js';
9
9
  import formDataToJSON from '../helpers/formDataToJSON.js';
10
- import adapters from '../adapters/index.js';
11
10
 
12
11
  const DEFAULT_CONTENT_TYPE = {
13
- 'Content-Type': 'application/x-www-form-urlencoded'
12
+ 'Content-Type': undefined
14
13
  };
15
14
 
16
- /**
17
- * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
18
- * adapter
19
- *
20
- * @returns {Function}
21
- */
22
- function getDefaultAdapter() {
23
- let adapter;
24
- if (typeof XMLHttpRequest !== 'undefined') {
25
- // For browsers use XHR adapter
26
- adapter = adapters.getAdapter('xhr');
27
- } else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
28
- // For node use HTTP adapter
29
- adapter = adapters.getAdapter('http');
30
- }
31
- return adapter;
32
- }
33
-
34
15
  /**
35
16
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
36
17
  * of the input
@@ -60,7 +41,7 @@ const defaults = {
60
41
 
61
42
  transitional: transitionalDefaults,
62
43
 
63
- adapter: getDefaultAdapter(),
44
+ adapter: ['xhr', 'http'],
64
45
 
65
46
  transformRequest: [function transformRequest(data, headers) {
66
47
  const contentType = headers.getContentType() || '';
@@ -1,2 +1,2 @@
1
- import FormData from 'form-data';
2
- export default FormData;
1
+ import _FormData from 'form-data';
2
+ export default typeof FormData !== 'undefined' ? FormData : _FormData;
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.1.3";
1
+ export const VERSION = "1.3.3";
@@ -0,0 +1,71 @@
1
+ const HttpStatusCode = {
2
+ Continue: 100,
3
+ SwitchingProtocols: 101,
4
+ Processing: 102,
5
+ EarlyHints: 103,
6
+ Ok: 200,
7
+ Created: 201,
8
+ Accepted: 202,
9
+ NonAuthoritativeInformation: 203,
10
+ NoContent: 204,
11
+ ResetContent: 205,
12
+ PartialContent: 206,
13
+ MultiStatus: 207,
14
+ AlreadyReported: 208,
15
+ ImUsed: 226,
16
+ MultipleChoices: 300,
17
+ MovedPermanently: 301,
18
+ Found: 302,
19
+ SeeOther: 303,
20
+ NotModified: 304,
21
+ UseProxy: 305,
22
+ Unused: 306,
23
+ TemporaryRedirect: 307,
24
+ PermanentRedirect: 308,
25
+ BadRequest: 400,
26
+ Unauthorized: 401,
27
+ PaymentRequired: 402,
28
+ Forbidden: 403,
29
+ NotFound: 404,
30
+ MethodNotAllowed: 405,
31
+ NotAcceptable: 406,
32
+ ProxyAuthenticationRequired: 407,
33
+ RequestTimeout: 408,
34
+ Conflict: 409,
35
+ Gone: 410,
36
+ LengthRequired: 411,
37
+ PreconditionFailed: 412,
38
+ PayloadTooLarge: 413,
39
+ UriTooLong: 414,
40
+ UnsupportedMediaType: 415,
41
+ RangeNotSatisfiable: 416,
42
+ ExpectationFailed: 417,
43
+ ImATeapot: 418,
44
+ MisdirectedRequest: 421,
45
+ UnprocessableEntity: 422,
46
+ Locked: 423,
47
+ FailedDependency: 424,
48
+ TooEarly: 425,
49
+ UpgradeRequired: 426,
50
+ PreconditionRequired: 428,
51
+ TooManyRequests: 429,
52
+ RequestHeaderFieldsTooLarge: 431,
53
+ UnavailableForLegalReasons: 451,
54
+ InternalServerError: 500,
55
+ NotImplemented: 501,
56
+ BadGateway: 502,
57
+ ServiceUnavailable: 503,
58
+ GatewayTimeout: 504,
59
+ HttpVersionNotSupported: 505,
60
+ VariantAlsoNegotiates: 506,
61
+ InsufficientStorage: 507,
62
+ LoopDetected: 508,
63
+ NotExtended: 510,
64
+ NetworkAuthenticationRequired: 511,
65
+ };
66
+
67
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
68
+ HttpStatusCode[value] = key;
69
+ });
70
+
71
+ export default HttpStatusCode;