@aligent/cdk-prerender-proxy 0.2.5-experimental4 → 0.2.5
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.
- package/lib/error-response-construct.d.ts +0 -1
- package/lib/error-response-construct.js +4 -5
- package/lib/handlers/cache-control.ts +21 -0
- package/lib/handlers/error-response.ts +51 -0
- package/lib/handlers/node_modules/.package-lock.json +55 -0
- package/lib/handlers/node_modules/@types/aws-lambda/LICENSE +21 -0
- package/lib/handlers/node_modules/@types/aws-lambda/README.md +16 -0
- package/lib/handlers/node_modules/@types/aws-lambda/common/api-gateway.d.ts +79 -0
- package/lib/handlers/node_modules/@types/aws-lambda/common/cloudfront.d.ts +79 -0
- package/lib/handlers/node_modules/@types/aws-lambda/handler.d.ts +171 -0
- package/lib/handlers/node_modules/@types/aws-lambda/index.d.ts +85 -0
- package/lib/handlers/node_modules/@types/aws-lambda/package.json +210 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/alb.d.ts +48 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/api-gateway-authorizer.d.ts +174 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts +187 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/appsync-resolver.d.ts +51 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudformation-custom-resource.d.ts +68 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts +20 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudfront-response.d.ts +21 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudwatch-events.d.ts +8 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cloudwatch-logs.d.ts +37 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codebuild-cloudwatch-state.d.ts +104 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-action.d.ts +31 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-pipeline.d.ts +32 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch-stage.d.ts +23 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline-cloudwatch.d.ts +11 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/codepipeline.d.ts +55 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/_common.d.ts +41 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/create-auth-challenge.d.ts +22 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/custom-email-sender.d.ts +86 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/custom-message.d.ts +44 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/define-auth-challenge.d.ts +21 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/index.d.ts +119 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/post-authentication.d.ts +15 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/post-confirmation.d.ts +22 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-authentication.d.ts +15 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-signup.d.ts +31 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/pre-token-generation.d.ts +45 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/user-migration.d.ts +39 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/cognito-user-pool-trigger/verify-auth-challenge-response.d.ts +20 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/connect-contact-flow.d.ts +65 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/dynamodb-stream.d.ts +45 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/eventbridge.d.ts +18 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/iot.d.ts +28 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/kinesis-firehose-transformation.d.ts +45 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/kinesis-stream.d.ts +28 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/lex.d.ts +116 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/msk.d.ts +21 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/s3-batch.d.ts +41 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/s3.d.ts +60 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/ses.d.ts +103 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/sns.d.ts +38 -0
- package/lib/handlers/node_modules/@types/aws-lambda/trigger/sqs.d.ts +46 -0
- package/lib/handlers/node_modules/@types/node/LICENSE +21 -0
- package/lib/handlers/node_modules/@types/node/README.md +16 -0
- package/lib/handlers/node_modules/@types/node/assert/strict.d.ts +4 -0
- package/lib/handlers/node_modules/@types/node/assert.d.ts +124 -0
- package/lib/handlers/node_modules/@types/node/async_hooks.d.ts +226 -0
- package/lib/handlers/node_modules/@types/node/base.d.ts +19 -0
- package/lib/handlers/node_modules/@types/node/buffer.d.ts +84 -0
- package/lib/handlers/node_modules/@types/node/child_process.d.ts +526 -0
- package/lib/handlers/node_modules/@types/node/cluster.d.ts +262 -0
- package/lib/handlers/node_modules/@types/node/console.d.ts +133 -0
- package/lib/handlers/node_modules/@types/node/constants.d.ts +13 -0
- package/lib/handlers/node_modules/@types/node/crypto.d.ts +1580 -0
- package/lib/handlers/node_modules/@types/node/dgram.d.ts +141 -0
- package/lib/handlers/node_modules/@types/node/diagnostic_channel.d.ts +34 -0
- package/lib/handlers/node_modules/@types/node/dns/promises.d.ts +97 -0
- package/lib/handlers/node_modules/@types/node/dns.d.ts +322 -0
- package/lib/handlers/node_modules/@types/node/domain.d.ts +24 -0
- package/lib/handlers/node_modules/@types/node/events.d.ts +93 -0
- package/lib/handlers/node_modules/@types/node/fs/promises.d.ts +592 -0
- package/lib/handlers/node_modules/@types/node/fs.d.ts +2239 -0
- package/lib/handlers/node_modules/@types/node/globals.d.ts +655 -0
- package/lib/handlers/node_modules/@types/node/globals.global.d.ts +1 -0
- package/lib/handlers/node_modules/@types/node/http.d.ts +434 -0
- package/lib/handlers/node_modules/@types/node/http2.d.ts +976 -0
- package/lib/handlers/node_modules/@types/node/https.d.ts +36 -0
- package/lib/handlers/node_modules/@types/node/index.d.ts +58 -0
- package/lib/handlers/node_modules/@types/node/inspector.d.ts +3041 -0
- package/lib/handlers/node_modules/@types/node/module.d.ts +52 -0
- package/lib/handlers/node_modules/@types/node/net.d.ts +326 -0
- package/lib/handlers/node_modules/@types/node/os.d.ts +239 -0
- package/lib/handlers/node_modules/@types/node/package.json +232 -0
- package/lib/handlers/node_modules/@types/node/path.d.ts +163 -0
- package/lib/handlers/node_modules/@types/node/perf_hooks.d.ts +310 -0
- package/lib/handlers/node_modules/@types/node/process.d.ts +461 -0
- package/lib/handlers/node_modules/@types/node/punycode.d.ts +75 -0
- package/lib/handlers/node_modules/@types/node/querystring.d.ts +28 -0
- package/lib/handlers/node_modules/@types/node/readline.d.ts +192 -0
- package/lib/handlers/node_modules/@types/node/repl.d.ts +395 -0
- package/lib/handlers/node_modules/@types/node/stream/promises.d.ts +67 -0
- package/lib/handlers/node_modules/@types/node/stream.d.ts +471 -0
- package/lib/handlers/node_modules/@types/node/string_decoder.d.ts +7 -0
- package/lib/handlers/node_modules/@types/node/timers/promises.d.ts +21 -0
- package/lib/handlers/node_modules/@types/node/timers.d.ts +27 -0
- package/lib/handlers/node_modules/@types/node/tls.d.ts +793 -0
- package/lib/handlers/node_modules/@types/node/trace_events.d.ts +61 -0
- package/lib/handlers/node_modules/@types/node/ts3.6/assert.d.ts +98 -0
- package/lib/handlers/node_modules/@types/node/ts3.6/base.d.ts +68 -0
- package/lib/handlers/node_modules/@types/node/ts3.6/index.d.ts +7 -0
- package/lib/handlers/node_modules/@types/node/tty.d.ts +66 -0
- package/lib/handlers/node_modules/@types/node/url.d.ts +116 -0
- package/lib/handlers/node_modules/@types/node/util/types.d.ts +53 -0
- package/lib/handlers/node_modules/@types/node/util.d.ts +156 -0
- package/lib/handlers/node_modules/@types/node/v8.d.ts +198 -0
- package/lib/handlers/node_modules/@types/node/vm.d.ts +152 -0
- package/lib/handlers/node_modules/@types/node/wasi.d.ts +86 -0
- package/lib/handlers/node_modules/@types/node/worker_threads.d.ts +282 -0
- package/lib/handlers/node_modules/@types/node/zlib.d.ts +361 -0
- package/lib/handlers/node_modules/axios/CHANGELOG.md +685 -0
- package/lib/handlers/node_modules/axios/LICENSE +19 -0
- package/lib/handlers/node_modules/axios/README.md +800 -0
- package/lib/handlers/node_modules/axios/UPGRADE_GUIDE.md +162 -0
- package/lib/handlers/node_modules/axios/dist/axios.js +1756 -0
- package/lib/handlers/node_modules/axios/dist/axios.map +1 -0
- package/lib/handlers/node_modules/axios/dist/axios.min.js +3 -0
- package/lib/handlers/node_modules/axios/dist/axios.min.map +1 -0
- package/lib/handlers/node_modules/axios/index.d.ts +161 -0
- package/lib/handlers/node_modules/axios/index.js +1 -0
- package/lib/handlers/node_modules/axios/lib/adapters/README.md +37 -0
- package/lib/handlers/node_modules/axios/lib/adapters/http.js +303 -0
- package/lib/handlers/node_modules/axios/lib/adapters/xhr.js +179 -0
- package/lib/handlers/node_modules/axios/lib/axios.js +56 -0
- package/lib/handlers/node_modules/axios/lib/cancel/Cancel.js +19 -0
- package/lib/handlers/node_modules/axios/lib/cancel/CancelToken.js +57 -0
- package/lib/handlers/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/lib/handlers/node_modules/axios/lib/core/Axios.js +95 -0
- package/lib/handlers/node_modules/axios/lib/core/InterceptorManager.js +52 -0
- package/lib/handlers/node_modules/axios/lib/core/README.md +7 -0
- package/lib/handlers/node_modules/axios/lib/core/buildFullPath.js +20 -0
- package/lib/handlers/node_modules/axios/lib/core/createError.js +18 -0
- package/lib/handlers/node_modules/axios/lib/core/dispatchRequest.js +79 -0
- package/lib/handlers/node_modules/axios/lib/core/enhanceError.js +42 -0
- package/lib/handlers/node_modules/axios/lib/core/mergeConfig.js +87 -0
- package/lib/handlers/node_modules/axios/lib/core/settle.js +25 -0
- package/lib/handlers/node_modules/axios/lib/core/transformData.js +20 -0
- package/lib/handlers/node_modules/axios/lib/defaults.js +98 -0
- package/lib/handlers/node_modules/axios/lib/helpers/README.md +7 -0
- package/lib/handlers/node_modules/axios/lib/helpers/bind.js +11 -0
- package/lib/handlers/node_modules/axios/lib/helpers/buildURL.js +70 -0
- package/lib/handlers/node_modules/axios/lib/helpers/combineURLs.js +14 -0
- package/lib/handlers/node_modules/axios/lib/helpers/cookies.js +53 -0
- package/lib/handlers/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/lib/handlers/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/lib/handlers/node_modules/axios/lib/helpers/isAxiosError.js +11 -0
- package/lib/handlers/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/lib/handlers/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/lib/handlers/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
- package/lib/handlers/node_modules/axios/lib/helpers/spread.js +27 -0
- package/lib/handlers/node_modules/axios/lib/utils.js +351 -0
- package/lib/handlers/node_modules/axios/package.json +86 -0
- package/lib/handlers/node_modules/buffer-from/LICENSE +21 -0
- package/lib/handlers/node_modules/buffer-from/index.js +69 -0
- package/lib/handlers/node_modules/buffer-from/package.json +19 -0
- package/lib/handlers/node_modules/buffer-from/readme.md +69 -0
- package/lib/handlers/node_modules/follow-redirects/LICENSE +18 -0
- package/lib/handlers/node_modules/follow-redirects/README.md +148 -0
- package/lib/handlers/node_modules/follow-redirects/debug.js +14 -0
- package/lib/handlers/node_modules/follow-redirects/http.js +1 -0
- package/lib/handlers/node_modules/follow-redirects/https.js +1 -0
- package/lib/handlers/node_modules/follow-redirects/index.js +531 -0
- package/lib/handlers/node_modules/follow-redirects/package.json +59 -0
- package/lib/handlers/node_modules/source-map/CHANGELOG.md +301 -0
- package/lib/handlers/node_modules/source-map/LICENSE +28 -0
- package/lib/handlers/node_modules/source-map/README.md +742 -0
- package/lib/handlers/node_modules/source-map/dist/source-map.debug.js +3234 -0
- package/lib/handlers/node_modules/source-map/dist/source-map.js +3233 -0
- package/lib/handlers/node_modules/source-map/dist/source-map.min.js +2 -0
- package/lib/handlers/node_modules/source-map/dist/source-map.min.js.map +1 -0
- package/lib/handlers/node_modules/source-map/lib/array-set.js +121 -0
- package/lib/handlers/node_modules/source-map/lib/base64-vlq.js +140 -0
- package/lib/handlers/node_modules/source-map/lib/base64.js +67 -0
- package/lib/handlers/node_modules/source-map/lib/binary-search.js +111 -0
- package/lib/handlers/node_modules/source-map/lib/mapping-list.js +79 -0
- package/lib/handlers/node_modules/source-map/lib/quick-sort.js +114 -0
- package/lib/handlers/node_modules/source-map/lib/source-map-consumer.js +1145 -0
- package/lib/handlers/node_modules/source-map/lib/source-map-generator.js +425 -0
- package/lib/handlers/node_modules/source-map/lib/source-node.js +413 -0
- package/lib/handlers/node_modules/source-map/lib/util.js +488 -0
- package/lib/handlers/node_modules/source-map/package.json +73 -0
- package/lib/handlers/node_modules/source-map/source-map.d.ts +98 -0
- package/lib/handlers/node_modules/source-map/source-map.js +8 -0
- package/lib/handlers/node_modules/source-map-support/LICENSE.md +21 -0
- package/lib/handlers/node_modules/source-map-support/README.md +284 -0
- package/lib/handlers/node_modules/source-map-support/browser-source-map-support.js +114 -0
- package/lib/handlers/node_modules/source-map-support/package.json +31 -0
- package/lib/handlers/node_modules/source-map-support/register.js +1 -0
- package/lib/handlers/node_modules/source-map-support/source-map-support.js +604 -0
- package/lib/handlers/package-lock.json +108 -0
- package/lib/handlers/package.json +13 -0
- package/lib/handlers/prerender-check.ts +34 -0
- package/lib/handlers/prerender.ts +43 -0
- package/lib/handlers/tsconfig.json +24 -0
- package/lib/prerender-cf-cache-control-construct.d.ts +0 -1
- package/lib/prerender-cf-cache-control-construct.js +4 -5
- package/lib/prerender-check-construct.d.ts +0 -1
- package/lib/prerender-check-construct.js +4 -5
- package/lib/prerender-construct.d.ts +0 -1
- package/lib/prerender-construct.js +4 -5
- package/package.json +3 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./utils');
|
|
4
|
+
var bind = require('./helpers/bind');
|
|
5
|
+
var Axios = require('./core/Axios');
|
|
6
|
+
var mergeConfig = require('./core/mergeConfig');
|
|
7
|
+
var defaults = require('./defaults');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create an instance of Axios
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} defaultConfig The default config for the instance
|
|
13
|
+
* @return {Axios} A new instance of Axios
|
|
14
|
+
*/
|
|
15
|
+
function createInstance(defaultConfig) {
|
|
16
|
+
var context = new Axios(defaultConfig);
|
|
17
|
+
var instance = bind(Axios.prototype.request, context);
|
|
18
|
+
|
|
19
|
+
// Copy axios.prototype to instance
|
|
20
|
+
utils.extend(instance, Axios.prototype, context);
|
|
21
|
+
|
|
22
|
+
// Copy context to instance
|
|
23
|
+
utils.extend(instance, context);
|
|
24
|
+
|
|
25
|
+
return instance;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Create the default instance to be exported
|
|
29
|
+
var axios = createInstance(defaults);
|
|
30
|
+
|
|
31
|
+
// Expose Axios class to allow class inheritance
|
|
32
|
+
axios.Axios = Axios;
|
|
33
|
+
|
|
34
|
+
// Factory for creating new instances
|
|
35
|
+
axios.create = function create(instanceConfig) {
|
|
36
|
+
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Expose Cancel & CancelToken
|
|
40
|
+
axios.Cancel = require('./cancel/Cancel');
|
|
41
|
+
axios.CancelToken = require('./cancel/CancelToken');
|
|
42
|
+
axios.isCancel = require('./cancel/isCancel');
|
|
43
|
+
|
|
44
|
+
// Expose all/spread
|
|
45
|
+
axios.all = function all(promises) {
|
|
46
|
+
return Promise.all(promises);
|
|
47
|
+
};
|
|
48
|
+
axios.spread = require('./helpers/spread');
|
|
49
|
+
|
|
50
|
+
// Expose isAxiosError
|
|
51
|
+
axios.isAxiosError = require('./helpers/isAxiosError');
|
|
52
|
+
|
|
53
|
+
module.exports = axios;
|
|
54
|
+
|
|
55
|
+
// Allow use of default import syntax in TypeScript
|
|
56
|
+
module.exports.default = axios;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A `Cancel` is an object that is thrown when an operation is canceled.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @param {string=} message The message.
|
|
8
|
+
*/
|
|
9
|
+
function Cancel(message) {
|
|
10
|
+
this.message = message;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Cancel.prototype.toString = function toString() {
|
|
14
|
+
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Cancel.prototype.__CANCEL__ = true;
|
|
18
|
+
|
|
19
|
+
module.exports = Cancel;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Cancel = require('./Cancel');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @param {Function} executor The executor function.
|
|
10
|
+
*/
|
|
11
|
+
function CancelToken(executor) {
|
|
12
|
+
if (typeof executor !== 'function') {
|
|
13
|
+
throw new TypeError('executor must be a function.');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var resolvePromise;
|
|
17
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
18
|
+
resolvePromise = resolve;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var token = this;
|
|
22
|
+
executor(function cancel(message) {
|
|
23
|
+
if (token.reason) {
|
|
24
|
+
// Cancellation has already been requested
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
token.reason = new Cancel(message);
|
|
29
|
+
resolvePromise(token.reason);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Throws a `Cancel` if cancellation has been requested.
|
|
35
|
+
*/
|
|
36
|
+
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
37
|
+
if (this.reason) {
|
|
38
|
+
throw this.reason;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
44
|
+
* cancels the `CancelToken`.
|
|
45
|
+
*/
|
|
46
|
+
CancelToken.source = function source() {
|
|
47
|
+
var cancel;
|
|
48
|
+
var token = new CancelToken(function executor(c) {
|
|
49
|
+
cancel = c;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
token: token,
|
|
53
|
+
cancel: cancel
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = CancelToken;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./../utils');
|
|
4
|
+
var buildURL = require('../helpers/buildURL');
|
|
5
|
+
var InterceptorManager = require('./InterceptorManager');
|
|
6
|
+
var dispatchRequest = require('./dispatchRequest');
|
|
7
|
+
var mergeConfig = require('./mergeConfig');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a new instance of Axios
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} instanceConfig The default config for the instance
|
|
13
|
+
*/
|
|
14
|
+
function Axios(instanceConfig) {
|
|
15
|
+
this.defaults = instanceConfig;
|
|
16
|
+
this.interceptors = {
|
|
17
|
+
request: new InterceptorManager(),
|
|
18
|
+
response: new InterceptorManager()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Dispatch a request
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} config The config specific for this request (merged with this.defaults)
|
|
26
|
+
*/
|
|
27
|
+
Axios.prototype.request = function request(config) {
|
|
28
|
+
/*eslint no-param-reassign:0*/
|
|
29
|
+
// Allow for axios('example/url'[, config]) a la fetch API
|
|
30
|
+
if (typeof config === 'string') {
|
|
31
|
+
config = arguments[1] || {};
|
|
32
|
+
config.url = arguments[0];
|
|
33
|
+
} else {
|
|
34
|
+
config = config || {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
config = mergeConfig(this.defaults, config);
|
|
38
|
+
|
|
39
|
+
// Set config.method
|
|
40
|
+
if (config.method) {
|
|
41
|
+
config.method = config.method.toLowerCase();
|
|
42
|
+
} else if (this.defaults.method) {
|
|
43
|
+
config.method = this.defaults.method.toLowerCase();
|
|
44
|
+
} else {
|
|
45
|
+
config.method = 'get';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Hook up interceptors middleware
|
|
49
|
+
var chain = [dispatchRequest, undefined];
|
|
50
|
+
var promise = Promise.resolve(config);
|
|
51
|
+
|
|
52
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
53
|
+
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
57
|
+
chain.push(interceptor.fulfilled, interceptor.rejected);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
while (chain.length) {
|
|
61
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return promise;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Axios.prototype.getUri = function getUri(config) {
|
|
68
|
+
config = mergeConfig(this.defaults, config);
|
|
69
|
+
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Provide aliases for supported request methods
|
|
73
|
+
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
74
|
+
/*eslint func-names:0*/
|
|
75
|
+
Axios.prototype[method] = function(url, config) {
|
|
76
|
+
return this.request(mergeConfig(config || {}, {
|
|
77
|
+
method: method,
|
|
78
|
+
url: url,
|
|
79
|
+
data: (config || {}).data
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
85
|
+
/*eslint func-names:0*/
|
|
86
|
+
Axios.prototype[method] = function(url, data, config) {
|
|
87
|
+
return this.request(mergeConfig(config || {}, {
|
|
88
|
+
method: method,
|
|
89
|
+
url: url,
|
|
90
|
+
data: data
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
module.exports = Axios;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./../utils');
|
|
4
|
+
|
|
5
|
+
function InterceptorManager() {
|
|
6
|
+
this.handlers = [];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Add a new interceptor to the stack
|
|
11
|
+
*
|
|
12
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
13
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
14
|
+
*
|
|
15
|
+
* @return {Number} An ID used to remove interceptor later
|
|
16
|
+
*/
|
|
17
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
|
18
|
+
this.handlers.push({
|
|
19
|
+
fulfilled: fulfilled,
|
|
20
|
+
rejected: rejected
|
|
21
|
+
});
|
|
22
|
+
return this.handlers.length - 1;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Remove an interceptor from the stack
|
|
27
|
+
*
|
|
28
|
+
* @param {Number} id The ID that was returned by `use`
|
|
29
|
+
*/
|
|
30
|
+
InterceptorManager.prototype.eject = function eject(id) {
|
|
31
|
+
if (this.handlers[id]) {
|
|
32
|
+
this.handlers[id] = null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Iterate over all the registered interceptors
|
|
38
|
+
*
|
|
39
|
+
* This method is particularly useful for skipping over any
|
|
40
|
+
* interceptors that may have become `null` calling `eject`.
|
|
41
|
+
*
|
|
42
|
+
* @param {Function} fn The function to call for each interceptor
|
|
43
|
+
*/
|
|
44
|
+
InterceptorManager.prototype.forEach = function forEach(fn) {
|
|
45
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
46
|
+
if (h !== null) {
|
|
47
|
+
fn(h);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = InterceptorManager;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# axios // core
|
|
2
|
+
|
|
3
|
+
The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
|
|
4
|
+
|
|
5
|
+
- Dispatching requests
|
|
6
|
+
- Managing interceptors
|
|
7
|
+
- Handling config
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isAbsoluteURL = require('../helpers/isAbsoluteURL');
|
|
4
|
+
var combineURLs = require('../helpers/combineURLs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
8
|
+
* only when the requestedURL is not already an absolute URL.
|
|
9
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} baseURL The base URL
|
|
12
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
|
13
|
+
* @returns {string} The combined full path
|
|
14
|
+
*/
|
|
15
|
+
module.exports = function buildFullPath(baseURL, requestedURL) {
|
|
16
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
17
|
+
return combineURLs(baseURL, requestedURL);
|
|
18
|
+
}
|
|
19
|
+
return requestedURL;
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var enhanceError = require('./enhanceError');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} message The error message.
|
|
9
|
+
* @param {Object} config The config.
|
|
10
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
11
|
+
* @param {Object} [request] The request.
|
|
12
|
+
* @param {Object} [response] The response.
|
|
13
|
+
* @returns {Error} The created error.
|
|
14
|
+
*/
|
|
15
|
+
module.exports = function createError(message, config, code, request, response) {
|
|
16
|
+
var error = new Error(message);
|
|
17
|
+
return enhanceError(error, config, code, request, response);
|
|
18
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./../utils');
|
|
4
|
+
var transformData = require('./transformData');
|
|
5
|
+
var isCancel = require('../cancel/isCancel');
|
|
6
|
+
var defaults = require('../defaults');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Throws a `Cancel` if cancellation has been requested.
|
|
10
|
+
*/
|
|
11
|
+
function throwIfCancellationRequested(config) {
|
|
12
|
+
if (config.cancelToken) {
|
|
13
|
+
config.cancelToken.throwIfRequested();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Dispatch a request to the server using the configured adapter.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} config The config that is to be used for the request
|
|
21
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
22
|
+
*/
|
|
23
|
+
module.exports = function dispatchRequest(config) {
|
|
24
|
+
throwIfCancellationRequested(config);
|
|
25
|
+
|
|
26
|
+
// Ensure headers exist
|
|
27
|
+
config.headers = config.headers || {};
|
|
28
|
+
|
|
29
|
+
// Transform request data
|
|
30
|
+
config.data = transformData(
|
|
31
|
+
config.data,
|
|
32
|
+
config.headers,
|
|
33
|
+
config.transformRequest
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Flatten headers
|
|
37
|
+
config.headers = utils.merge(
|
|
38
|
+
config.headers.common || {},
|
|
39
|
+
config.headers[config.method] || {},
|
|
40
|
+
config.headers
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
utils.forEach(
|
|
44
|
+
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
45
|
+
function cleanHeaderConfig(method) {
|
|
46
|
+
delete config.headers[method];
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
var adapter = config.adapter || defaults.adapter;
|
|
51
|
+
|
|
52
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
53
|
+
throwIfCancellationRequested(config);
|
|
54
|
+
|
|
55
|
+
// Transform response data
|
|
56
|
+
response.data = transformData(
|
|
57
|
+
response.data,
|
|
58
|
+
response.headers,
|
|
59
|
+
config.transformResponse
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return response;
|
|
63
|
+
}, function onAdapterRejection(reason) {
|
|
64
|
+
if (!isCancel(reason)) {
|
|
65
|
+
throwIfCancellationRequested(config);
|
|
66
|
+
|
|
67
|
+
// Transform response data
|
|
68
|
+
if (reason && reason.response) {
|
|
69
|
+
reason.response.data = transformData(
|
|
70
|
+
reason.response.data,
|
|
71
|
+
reason.response.headers,
|
|
72
|
+
config.transformResponse
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return Promise.reject(reason);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Update an Error with the specified config, error code, and response.
|
|
5
|
+
*
|
|
6
|
+
* @param {Error} error The error to update.
|
|
7
|
+
* @param {Object} config The config.
|
|
8
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
9
|
+
* @param {Object} [request] The request.
|
|
10
|
+
* @param {Object} [response] The response.
|
|
11
|
+
* @returns {Error} The error.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function enhanceError(error, config, code, request, response) {
|
|
14
|
+
error.config = config;
|
|
15
|
+
if (code) {
|
|
16
|
+
error.code = code;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
error.request = request;
|
|
20
|
+
error.response = response;
|
|
21
|
+
error.isAxiosError = true;
|
|
22
|
+
|
|
23
|
+
error.toJSON = function toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
// Standard
|
|
26
|
+
message: this.message,
|
|
27
|
+
name: this.name,
|
|
28
|
+
// Microsoft
|
|
29
|
+
description: this.description,
|
|
30
|
+
number: this.number,
|
|
31
|
+
// Mozilla
|
|
32
|
+
fileName: this.fileName,
|
|
33
|
+
lineNumber: this.lineNumber,
|
|
34
|
+
columnNumber: this.columnNumber,
|
|
35
|
+
stack: this.stack,
|
|
36
|
+
// Axios
|
|
37
|
+
config: this.config,
|
|
38
|
+
code: this.code
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return error;
|
|
42
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Config-specific merge-function which creates a new config-object
|
|
7
|
+
* by merging two configuration objects together.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} config1
|
|
10
|
+
* @param {Object} config2
|
|
11
|
+
* @returns {Object} New object resulting from merging config2 to config1
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function mergeConfig(config1, config2) {
|
|
14
|
+
// eslint-disable-next-line no-param-reassign
|
|
15
|
+
config2 = config2 || {};
|
|
16
|
+
var config = {};
|
|
17
|
+
|
|
18
|
+
var valueFromConfig2Keys = ['url', 'method', 'data'];
|
|
19
|
+
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
|
|
20
|
+
var defaultToConfig2Keys = [
|
|
21
|
+
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
|
|
22
|
+
'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
|
23
|
+
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
|
|
24
|
+
'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
|
|
25
|
+
'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
|
|
26
|
+
];
|
|
27
|
+
var directMergeKeys = ['validateStatus'];
|
|
28
|
+
|
|
29
|
+
function getMergedValue(target, source) {
|
|
30
|
+
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
31
|
+
return utils.merge(target, source);
|
|
32
|
+
} else if (utils.isPlainObject(source)) {
|
|
33
|
+
return utils.merge({}, source);
|
|
34
|
+
} else if (utils.isArray(source)) {
|
|
35
|
+
return source.slice();
|
|
36
|
+
}
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function mergeDeepProperties(prop) {
|
|
41
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
42
|
+
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
43
|
+
} else if (!utils.isUndefined(config1[prop])) {
|
|
44
|
+
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
|
49
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
50
|
+
config[prop] = getMergedValue(undefined, config2[prop]);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
|
55
|
+
|
|
56
|
+
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
|
57
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
58
|
+
config[prop] = getMergedValue(undefined, config2[prop]);
|
|
59
|
+
} else if (!utils.isUndefined(config1[prop])) {
|
|
60
|
+
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
utils.forEach(directMergeKeys, function merge(prop) {
|
|
65
|
+
if (prop in config2) {
|
|
66
|
+
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
67
|
+
} else if (prop in config1) {
|
|
68
|
+
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var axiosKeys = valueFromConfig2Keys
|
|
73
|
+
.concat(mergeDeepPropertiesKeys)
|
|
74
|
+
.concat(defaultToConfig2Keys)
|
|
75
|
+
.concat(directMergeKeys);
|
|
76
|
+
|
|
77
|
+
var otherKeys = Object
|
|
78
|
+
.keys(config1)
|
|
79
|
+
.concat(Object.keys(config2))
|
|
80
|
+
.filter(function filterAxiosKeys(key) {
|
|
81
|
+
return axiosKeys.indexOf(key) === -1;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
utils.forEach(otherKeys, mergeDeepProperties);
|
|
85
|
+
|
|
86
|
+
return config;
|
|
87
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createError = require('./createError');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolve or reject a Promise based on response status.
|
|
7
|
+
*
|
|
8
|
+
* @param {Function} resolve A function that resolves the promise.
|
|
9
|
+
* @param {Function} reject A function that rejects the promise.
|
|
10
|
+
* @param {object} response The response.
|
|
11
|
+
*/
|
|
12
|
+
module.exports = function settle(resolve, reject, response) {
|
|
13
|
+
var validateStatus = response.config.validateStatus;
|
|
14
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
15
|
+
resolve(response);
|
|
16
|
+
} else {
|
|
17
|
+
reject(createError(
|
|
18
|
+
'Request failed with status code ' + response.status,
|
|
19
|
+
response.config,
|
|
20
|
+
null,
|
|
21
|
+
response.request,
|
|
22
|
+
response
|
|
23
|
+
));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./../utils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Transform the data for a request or a response
|
|
7
|
+
*
|
|
8
|
+
* @param {Object|String} data The data to be transformed
|
|
9
|
+
* @param {Array} headers The headers for the request or response
|
|
10
|
+
* @param {Array|Function} fns A single function or Array of functions
|
|
11
|
+
* @returns {*} The resulting transformed data
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function transformData(data, headers, fns) {
|
|
14
|
+
/*eslint no-param-reassign:0*/
|
|
15
|
+
utils.forEach(fns, function transform(fn) {
|
|
16
|
+
data = fn(data, headers);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./utils');
|
|
4
|
+
var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
|
5
|
+
|
|
6
|
+
var DEFAULT_CONTENT_TYPE = {
|
|
7
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function setContentTypeIfUnset(headers, value) {
|
|
11
|
+
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
|
12
|
+
headers['Content-Type'] = value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getDefaultAdapter() {
|
|
17
|
+
var adapter;
|
|
18
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
|
19
|
+
// For browsers use XHR adapter
|
|
20
|
+
adapter = require('./adapters/xhr');
|
|
21
|
+
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
|
22
|
+
// For node use HTTP adapter
|
|
23
|
+
adapter = require('./adapters/http');
|
|
24
|
+
}
|
|
25
|
+
return adapter;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var defaults = {
|
|
29
|
+
adapter: getDefaultAdapter(),
|
|
30
|
+
|
|
31
|
+
transformRequest: [function transformRequest(data, headers) {
|
|
32
|
+
normalizeHeaderName(headers, 'Accept');
|
|
33
|
+
normalizeHeaderName(headers, 'Content-Type');
|
|
34
|
+
if (utils.isFormData(data) ||
|
|
35
|
+
utils.isArrayBuffer(data) ||
|
|
36
|
+
utils.isBuffer(data) ||
|
|
37
|
+
utils.isStream(data) ||
|
|
38
|
+
utils.isFile(data) ||
|
|
39
|
+
utils.isBlob(data)
|
|
40
|
+
) {
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
if (utils.isArrayBufferView(data)) {
|
|
44
|
+
return data.buffer;
|
|
45
|
+
}
|
|
46
|
+
if (utils.isURLSearchParams(data)) {
|
|
47
|
+
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
|
48
|
+
return data.toString();
|
|
49
|
+
}
|
|
50
|
+
if (utils.isObject(data)) {
|
|
51
|
+
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
|
52
|
+
return JSON.stringify(data);
|
|
53
|
+
}
|
|
54
|
+
return data;
|
|
55
|
+
}],
|
|
56
|
+
|
|
57
|
+
transformResponse: [function transformResponse(data) {
|
|
58
|
+
/*eslint no-param-reassign:0*/
|
|
59
|
+
if (typeof data === 'string') {
|
|
60
|
+
try {
|
|
61
|
+
data = JSON.parse(data);
|
|
62
|
+
} catch (e) { /* Ignore */ }
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
}],
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
69
|
+
* timeout is not created.
|
|
70
|
+
*/
|
|
71
|
+
timeout: 0,
|
|
72
|
+
|
|
73
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
74
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
75
|
+
|
|
76
|
+
maxContentLength: -1,
|
|
77
|
+
maxBodyLength: -1,
|
|
78
|
+
|
|
79
|
+
validateStatus: function validateStatus(status) {
|
|
80
|
+
return status >= 200 && status < 300;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
defaults.headers = {
|
|
85
|
+
common: {
|
|
86
|
+
'Accept': 'application/json, text/plain, */*'
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
91
|
+
defaults.headers[method] = {};
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
95
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
module.exports = defaults;
|