axios 0.27.2 → 1.1.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.
- package/CHANGELOG.md +232 -920
- package/LICENSE +4 -16
- package/README.md +386 -103
- package/SECURITY.md +4 -3
- package/UPGRADE_GUIDE.md +1 -166
- package/bin/ssl_hotfix.js +22 -0
- package/dist/axios.js +2430 -2367
- package/dist/axios.js.map +1 -0
- package/dist/axios.min.js +2 -3
- package/dist/axios.min.js.map +1 -0
- package/dist/esm/axios.js +2950 -0
- package/dist/esm/axios.js.map +1 -0
- package/dist/esm/axios.min.js +2 -0
- package/dist/esm/axios.min.js.map +1 -0
- package/dist/node/axios.cjs +3764 -0
- package/dist/node/axios.cjs.map +1 -0
- package/gulpfile.js +88 -0
- package/index.d.ts +299 -70
- package/index.js +32 -1
- package/karma.conf.cjs +250 -0
- package/lib/adapters/http.js +378 -211
- package/lib/adapters/index.js +33 -0
- package/lib/adapters/xhr.js +81 -57
- package/lib/axios.js +34 -22
- package/lib/cancel/CancelToken.js +91 -89
- package/lib/cancel/CanceledError.js +9 -6
- package/lib/cancel/isCancel.js +2 -2
- package/lib/core/Axios.js +133 -98
- package/lib/core/AxiosError.js +22 -8
- package/lib/core/AxiosHeaders.js +268 -0
- package/lib/core/InterceptorManager.js +62 -45
- package/lib/core/buildFullPath.js +5 -4
- package/lib/core/dispatchRequest.js +21 -32
- package/lib/core/mergeConfig.js +8 -7
- package/lib/core/settle.js +6 -4
- package/lib/core/transformData.js +15 -9
- package/lib/defaults/index.js +77 -38
- package/lib/defaults/transitional.js +1 -1
- package/lib/env/classes/FormData.js +2 -0
- package/lib/env/data.js +1 -3
- package/lib/helpers/AxiosTransformStream.js +191 -0
- package/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/lib/helpers/bind.js +3 -7
- package/lib/helpers/buildURL.js +26 -33
- package/lib/helpers/combineURLs.js +3 -2
- package/lib/helpers/cookies.js +43 -44
- package/lib/helpers/deprecatedMethod.js +4 -2
- package/lib/helpers/formDataToJSON.js +92 -0
- package/lib/helpers/fromDataURI.js +53 -0
- package/lib/helpers/isAbsoluteURL.js +3 -2
- package/lib/helpers/isAxiosError.js +4 -3
- package/lib/helpers/isURLSameOrigin.js +44 -45
- package/lib/helpers/null.js +1 -1
- package/lib/helpers/parseHeaders.js +24 -22
- package/lib/helpers/parseProtocol.js +3 -3
- package/lib/helpers/speedometer.js +55 -0
- package/lib/helpers/spread.js +3 -2
- package/lib/helpers/throttle.js +33 -0
- package/lib/helpers/toFormData.js +193 -36
- package/lib/helpers/toURLEncodedForm.js +18 -0
- package/lib/helpers/validator.js +20 -15
- package/lib/platform/browser/classes/FormData.js +3 -0
- package/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/lib/platform/browser/index.js +43 -0
- package/lib/platform/index.js +3 -0
- package/lib/platform/node/classes/FormData.js +3 -0
- package/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/lib/platform/node/index.js +12 -0
- package/lib/utils.js +321 -178
- package/package.json +70 -23
- package/rollup.config.js +90 -0
- package/dist/axios.map +0 -1
- package/dist/axios.min.map +0 -1
- package/lib/defaults/env/FormData.js +0 -2
- package/lib/helpers/normalizeHeaderName.js +0 -12
@@ -1,54 +1,71 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
3
|
+
import utils from './../utils.js';
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class InterceptorManager {
|
6
|
+
constructor() {
|
7
|
+
this.handlers = [];
|
8
|
+
}
|
8
9
|
|
9
|
-
/**
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
10
|
+
/**
|
11
|
+
* Add a new interceptor to the stack
|
12
|
+
*
|
13
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
14
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
15
|
+
*
|
16
|
+
* @return {Number} An ID used to remove interceptor later
|
17
|
+
*/
|
18
|
+
use(fulfilled, rejected, options) {
|
19
|
+
this.handlers.push({
|
20
|
+
fulfilled,
|
21
|
+
rejected,
|
22
|
+
synchronous: options ? options.synchronous : false,
|
23
|
+
runWhen: options ? options.runWhen : null
|
24
|
+
});
|
25
|
+
return this.handlers.length - 1;
|
26
|
+
}
|
26
27
|
|
27
|
-
/**
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
/**
|
29
|
+
* Remove an interceptor from the stack
|
30
|
+
*
|
31
|
+
* @param {Number} id The ID that was returned by `use`
|
32
|
+
*
|
33
|
+
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
34
|
+
*/
|
35
|
+
eject(id) {
|
36
|
+
if (this.handlers[id]) {
|
37
|
+
this.handlers[id] = null;
|
38
|
+
}
|
35
39
|
}
|
36
|
-
};
|
37
40
|
|
38
|
-
/**
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
InterceptorManager.prototype.forEach = function forEach(fn) {
|
47
|
-
utils.forEach(this.handlers, function forEachHandler(h) {
|
48
|
-
if (h !== null) {
|
49
|
-
fn(h);
|
41
|
+
/**
|
42
|
+
* Clear all interceptors from the stack
|
43
|
+
*
|
44
|
+
* @returns {void}
|
45
|
+
*/
|
46
|
+
clear() {
|
47
|
+
if (this.handlers) {
|
48
|
+
this.handlers = [];
|
50
49
|
}
|
51
|
-
}
|
52
|
-
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Iterate over all the registered interceptors
|
54
|
+
*
|
55
|
+
* This method is particularly useful for skipping over any
|
56
|
+
* interceptors that may have become `null` calling `eject`.
|
57
|
+
*
|
58
|
+
* @param {Function} fn The function to call for each interceptor
|
59
|
+
*
|
60
|
+
* @returns {void}
|
61
|
+
*/
|
62
|
+
forEach(fn) {
|
63
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
64
|
+
if (h !== null) {
|
65
|
+
fn(h);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
}
|
53
70
|
|
54
|
-
|
71
|
+
export default InterceptorManager;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
|
4
|
+
import combineURLs from '../helpers/combineURLs.js';
|
5
5
|
|
6
6
|
/**
|
7
7
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
@@ -10,11 +10,12 @@ var combineURLs = require('../helpers/combineURLs');
|
|
10
10
|
*
|
11
11
|
* @param {string} baseURL The base URL
|
12
12
|
* @param {string} requestedURL Absolute or relative URL to combine
|
13
|
+
*
|
13
14
|
* @returns {string} The combined full path
|
14
15
|
*/
|
15
|
-
|
16
|
+
export default function buildFullPath(baseURL, requestedURL) {
|
16
17
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
17
18
|
return combineURLs(baseURL, requestedURL);
|
18
19
|
}
|
19
20
|
return requestedURL;
|
20
|
-
}
|
21
|
+
}
|
@@ -1,13 +1,17 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
import transformData from './transformData.js';
|
4
|
+
import isCancel from '../cancel/isCancel.js';
|
5
|
+
import defaults from '../defaults/index.js';
|
6
|
+
import CanceledError from '../cancel/CanceledError.js';
|
7
|
+
import AxiosHeaders from '../core/AxiosHeaders.js';
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Throws a `CanceledError` if cancellation has been requested.
|
11
|
+
*
|
12
|
+
* @param {Object} config The config that is to be used for the request
|
13
|
+
*
|
14
|
+
* @returns {void}
|
11
15
|
*/
|
12
16
|
function throwIfCancellationRequested(config) {
|
13
17
|
if (config.cancelToken) {
|
@@ -23,37 +27,21 @@ function throwIfCancellationRequested(config) {
|
|
23
27
|
* Dispatch a request to the server using the configured adapter.
|
24
28
|
*
|
25
29
|
* @param {object} config The config that is to be used for the request
|
30
|
+
*
|
26
31
|
* @returns {Promise} The Promise to be fulfilled
|
27
32
|
*/
|
28
|
-
|
33
|
+
export default function dispatchRequest(config) {
|
29
34
|
throwIfCancellationRequested(config);
|
30
35
|
|
31
|
-
|
32
|
-
config.headers = config.headers || {};
|
36
|
+
config.headers = AxiosHeaders.from(config.headers);
|
33
37
|
|
34
38
|
// Transform request data
|
35
39
|
config.data = transformData.call(
|
36
40
|
config,
|
37
|
-
config.data,
|
38
|
-
config.headers,
|
39
41
|
config.transformRequest
|
40
42
|
);
|
41
43
|
|
42
|
-
|
43
|
-
config.headers = utils.merge(
|
44
|
-
config.headers.common || {},
|
45
|
-
config.headers[config.method] || {},
|
46
|
-
config.headers
|
47
|
-
);
|
48
|
-
|
49
|
-
utils.forEach(
|
50
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
51
|
-
function cleanHeaderConfig(method) {
|
52
|
-
delete config.headers[method];
|
53
|
-
}
|
54
|
-
);
|
55
|
-
|
56
|
-
var adapter = config.adapter || defaults.adapter;
|
44
|
+
const adapter = config.adapter || defaults.adapter;
|
57
45
|
|
58
46
|
return adapter(config).then(function onAdapterResolution(response) {
|
59
47
|
throwIfCancellationRequested(config);
|
@@ -61,11 +49,12 @@ module.exports = function dispatchRequest(config) {
|
|
61
49
|
// Transform response data
|
62
50
|
response.data = transformData.call(
|
63
51
|
config,
|
64
|
-
|
65
|
-
response
|
66
|
-
config.transformResponse
|
52
|
+
config.transformResponse,
|
53
|
+
response
|
67
54
|
);
|
68
55
|
|
56
|
+
response.headers = AxiosHeaders.from(response.headers);
|
57
|
+
|
69
58
|
return response;
|
70
59
|
}, function onAdapterRejection(reason) {
|
71
60
|
if (!isCancel(reason)) {
|
@@ -75,13 +64,13 @@ module.exports = function dispatchRequest(config) {
|
|
75
64
|
if (reason && reason.response) {
|
76
65
|
reason.response.data = transformData.call(
|
77
66
|
config,
|
78
|
-
|
79
|
-
reason.response
|
80
|
-
config.transformResponse
|
67
|
+
config.transformResponse,
|
68
|
+
reason.response
|
81
69
|
);
|
70
|
+
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
82
71
|
}
|
83
72
|
}
|
84
73
|
|
85
74
|
return Promise.reject(reason);
|
86
75
|
});
|
87
|
-
}
|
76
|
+
}
|
package/lib/core/mergeConfig.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
3
|
+
import utils from '../utils.js';
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Config-specific merge-function which creates a new config-object
|
@@ -8,12 +8,13 @@ var utils = require('../utils');
|
|
8
8
|
*
|
9
9
|
* @param {Object} config1
|
10
10
|
* @param {Object} config2
|
11
|
+
*
|
11
12
|
* @returns {Object} New object resulting from merging config2 to config1
|
12
13
|
*/
|
13
|
-
|
14
|
+
export default function mergeConfig(config1, config2) {
|
14
15
|
// eslint-disable-next-line no-param-reassign
|
15
16
|
config2 = config2 || {};
|
16
|
-
|
17
|
+
const config = {};
|
17
18
|
|
18
19
|
function getMergedValue(target, source) {
|
19
20
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
@@ -60,7 +61,7 @@ module.exports = function mergeConfig(config1, config2) {
|
|
60
61
|
}
|
61
62
|
}
|
62
63
|
|
63
|
-
|
64
|
+
const mergeMap = {
|
64
65
|
'url': valueFromConfig2,
|
65
66
|
'method': valueFromConfig2,
|
66
67
|
'data': valueFromConfig2,
|
@@ -91,10 +92,10 @@ module.exports = function mergeConfig(config1, config2) {
|
|
91
92
|
};
|
92
93
|
|
93
94
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
94
|
-
|
95
|
-
|
95
|
+
const merge = mergeMap[prop] || mergeDeepProperties;
|
96
|
+
const configValue = merge(prop);
|
96
97
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
97
98
|
});
|
98
99
|
|
99
100
|
return config;
|
100
|
-
}
|
101
|
+
}
|
package/lib/core/settle.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
3
|
+
import AxiosError from './AxiosError.js';
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Resolve or reject a Promise based on response status.
|
@@ -8,9 +8,11 @@ var AxiosError = require('./AxiosError');
|
|
8
8
|
* @param {Function} resolve A function that resolves the promise.
|
9
9
|
* @param {Function} reject A function that rejects the promise.
|
10
10
|
* @param {object} response The response.
|
11
|
+
*
|
12
|
+
* @returns {object} The response.
|
11
13
|
*/
|
12
|
-
|
13
|
-
|
14
|
+
export default function settle(resolve, reject, response) {
|
15
|
+
const validateStatus = response.config.validateStatus;
|
14
16
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
15
17
|
resolve(response);
|
16
18
|
} else {
|
@@ -22,4 +24,4 @@ module.exports = function settle(resolve, reject, response) {
|
|
22
24
|
response
|
23
25
|
));
|
24
26
|
}
|
25
|
-
}
|
27
|
+
}
|
@@ -1,22 +1,28 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
import utils from './../utils.js';
|
4
|
+
import defaults from '../defaults/index.js';
|
5
|
+
import AxiosHeaders from '../core/AxiosHeaders.js';
|
5
6
|
|
6
7
|
/**
|
7
8
|
* Transform the data for a request or a response
|
8
9
|
*
|
9
|
-
* @param {Object|String} data The data to be transformed
|
10
|
-
* @param {Array} headers The headers for the request or response
|
11
10
|
* @param {Array|Function} fns A single function or Array of functions
|
11
|
+
* @param {?Object} response The response object
|
12
|
+
*
|
12
13
|
* @returns {*} The resulting transformed data
|
13
14
|
*/
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
export default function transformData(fns, response) {
|
16
|
+
const config = this || defaults;
|
17
|
+
const context = response || config;
|
18
|
+
const headers = AxiosHeaders.from(context.headers);
|
19
|
+
let data = context.data;
|
20
|
+
|
17
21
|
utils.forEach(fns, function transform(fn) {
|
18
|
-
data = fn.call(
|
22
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
19
23
|
});
|
20
24
|
|
25
|
+
headers.normalize();
|
26
|
+
|
21
27
|
return data;
|
22
|
-
}
|
28
|
+
}
|
package/lib/defaults/index.js
CHANGED
@@ -1,33 +1,46 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
import utils from '../utils.js';
|
4
|
+
import AxiosError from '../core/AxiosError.js';
|
5
|
+
import transitionalDefaults from './transitional.js';
|
6
|
+
import toFormData from '../helpers/toFormData.js';
|
7
|
+
import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
|
8
|
+
import platform from '../platform/index.js';
|
9
|
+
import formDataToJSON from '../helpers/formDataToJSON.js';
|
10
|
+
import adapters from '../adapters/index.js';
|
11
|
+
|
12
|
+
const DEFAULT_CONTENT_TYPE = {
|
10
13
|
'Content-Type': 'application/x-www-form-urlencoded'
|
11
14
|
};
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
|
16
|
+
/**
|
17
|
+
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
18
|
+
* adapter
|
19
|
+
*
|
20
|
+
* @returns {Function}
|
21
|
+
*/
|
19
22
|
function getDefaultAdapter() {
|
20
|
-
|
23
|
+
let adapter;
|
21
24
|
if (typeof XMLHttpRequest !== 'undefined') {
|
22
25
|
// For browsers use XHR adapter
|
23
|
-
adapter =
|
24
|
-
} else if (typeof process !== 'undefined' &&
|
26
|
+
adapter = adapters.getAdapter('xhr');
|
27
|
+
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
25
28
|
// For node use HTTP adapter
|
26
|
-
adapter =
|
29
|
+
adapter = adapters.getAdapter('http');
|
27
30
|
}
|
28
31
|
return adapter;
|
29
32
|
}
|
30
33
|
|
34
|
+
/**
|
35
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
36
|
+
* of the input
|
37
|
+
*
|
38
|
+
* @param {any} rawValue - The value to be stringified.
|
39
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
40
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
41
|
+
*
|
42
|
+
* @returns {string} A stringified version of the rawValue.
|
43
|
+
*/
|
31
44
|
function stringifySafely(rawValue, parser, encoder) {
|
32
45
|
if (utils.isString(rawValue)) {
|
33
46
|
try {
|
@@ -43,18 +56,31 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
43
56
|
return (encoder || JSON.stringify)(rawValue);
|
44
57
|
}
|
45
58
|
|
46
|
-
|
59
|
+
const defaults = {
|
47
60
|
|
48
61
|
transitional: transitionalDefaults,
|
49
62
|
|
50
63
|
adapter: getDefaultAdapter(),
|
51
64
|
|
52
65
|
transformRequest: [function transformRequest(data, headers) {
|
53
|
-
|
54
|
-
|
66
|
+
const contentType = headers.getContentType() || '';
|
67
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
68
|
+
const isObjectPayload = utils.isObject(data);
|
69
|
+
|
70
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
71
|
+
data = new FormData(data);
|
72
|
+
}
|
73
|
+
|
74
|
+
const isFormData = utils.isFormData(data);
|
75
|
+
|
76
|
+
if (isFormData) {
|
77
|
+
if (!hasJSONContentType) {
|
78
|
+
return data;
|
79
|
+
}
|
80
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
81
|
+
}
|
55
82
|
|
56
|
-
if (utils.
|
57
|
-
utils.isArrayBuffer(data) ||
|
83
|
+
if (utils.isArrayBuffer(data) ||
|
58
84
|
utils.isBuffer(data) ||
|
59
85
|
utils.isStream(data) ||
|
60
86
|
utils.isFile(data) ||
|
@@ -66,20 +92,30 @@ var defaults = {
|
|
66
92
|
return data.buffer;
|
67
93
|
}
|
68
94
|
if (utils.isURLSearchParams(data)) {
|
69
|
-
|
95
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
70
96
|
return data.toString();
|
71
97
|
}
|
72
98
|
|
73
|
-
|
74
|
-
|
99
|
+
let isFileList;
|
100
|
+
|
101
|
+
if (isObjectPayload) {
|
102
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
103
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
104
|
+
}
|
105
|
+
|
106
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
107
|
+
const _FormData = this.env && this.env.FormData;
|
75
108
|
|
76
|
-
|
109
|
+
return toFormData(
|
110
|
+
isFileList ? {'files[]': data} : data,
|
111
|
+
_FormData && new _FormData(),
|
112
|
+
this.formSerializer
|
113
|
+
);
|
114
|
+
}
|
115
|
+
}
|
77
116
|
|
78
|
-
if (
|
79
|
-
|
80
|
-
return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
|
81
|
-
} else if (isObjectPayload || contentType === 'application/json') {
|
82
|
-
setContentTypeIfUnset(headers, 'application/json');
|
117
|
+
if (isObjectPayload || hasJSONContentType ) {
|
118
|
+
headers.setContentType('application/json', false);
|
83
119
|
return stringifySafely(data);
|
84
120
|
}
|
85
121
|
|
@@ -87,12 +123,14 @@ var defaults = {
|
|
87
123
|
}],
|
88
124
|
|
89
125
|
transformResponse: [function transformResponse(data) {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
126
|
+
const transitional = this.transitional || defaults.transitional;
|
127
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
128
|
+
const JSONRequested = this.responseType === 'json';
|
129
|
+
|
130
|
+
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
131
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
132
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
94
133
|
|
95
|
-
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
96
134
|
try {
|
97
135
|
return JSON.parse(data);
|
98
136
|
} catch (e) {
|
@@ -121,7 +159,8 @@ var defaults = {
|
|
121
159
|
maxBodyLength: -1,
|
122
160
|
|
123
161
|
env: {
|
124
|
-
FormData:
|
162
|
+
FormData: platform.classes.FormData,
|
163
|
+
Blob: platform.classes.Blob
|
125
164
|
},
|
126
165
|
|
127
166
|
validateStatus: function validateStatus(status) {
|
@@ -143,4 +182,4 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
143
182
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
144
183
|
});
|
145
184
|
|
146
|
-
|
185
|
+
export default defaults;
|
package/lib/env/data.js
CHANGED