Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/axios/lib/axios.js
1126 views
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
// Factory for creating new instances
26
instance.create = function create(instanceConfig) {
27
return createInstance(mergeConfig(defaultConfig, instanceConfig));
28
};
29
30
return instance;
31
}
32
33
// Create the default instance to be exported
34
var axios = createInstance(defaults);
35
36
// Expose Axios class to allow class inheritance
37
axios.Axios = Axios;
38
39
// Expose Cancel & CancelToken
40
axios.Cancel = require('./cancel/Cancel');
41
axios.CancelToken = require('./cancel/CancelToken');
42
axios.isCancel = require('./cancel/isCancel');
43
axios.VERSION = require('./env/data').version;
44
45
// Expose all/spread
46
axios.all = function all(promises) {
47
return Promise.all(promises);
48
};
49
axios.spread = require('./helpers/spread');
50
51
// Expose isAxiosError
52
axios.isAxiosError = require('./helpers/isAxiosError');
53
54
module.exports = axios;
55
56
// Allow use of default import syntax in TypeScript
57
module.exports.default = axios;
58
59