1 | 'use strict';
|
2 |
|
3 | import utils from './utils.js';
|
4 | import bind from './helpers/bind.js';
|
5 | import Axios from './core/Axios.js';
|
6 | import mergeConfig from './core/mergeConfig.js';
|
7 | import defaults from './defaults/index.js';
|
8 | import formDataToJSON from './helpers/formDataToJSON.js';
|
9 | import CanceledError from './cancel/CanceledError.js';
|
10 | import CancelToken from './cancel/CancelToken.js';
|
11 | import isCancel from './cancel/isCancel.js';
|
12 | import {VERSION} from './env/data.js';
|
13 | import toFormData from './helpers/toFormData.js';
|
14 | import AxiosError from './core/AxiosError.js';
|
15 | import spread from './helpers/spread.js';
|
16 | import isAxiosError from './helpers/isAxiosError.js';
|
17 | import AxiosHeaders from "./core/AxiosHeaders.js";
|
18 | import adapters from './adapters/adapters.js';
|
19 | import HttpStatusCode from './helpers/HttpStatusCode.js';
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | function createInstance(defaultConfig) {
|
29 | const context = new Axios(defaultConfig);
|
30 | const instance = bind(Axios.prototype.request, context);
|
31 |
|
32 |
|
33 | utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
34 |
|
35 |
|
36 | utils.extend(instance, context, null, {allOwnKeys: true});
|
37 |
|
38 |
|
39 | instance.create = function create(instanceConfig) {
|
40 | return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
41 | };
|
42 |
|
43 | return instance;
|
44 | }
|
45 |
|
46 |
|
47 | const axios = createInstance(defaults);
|
48 |
|
49 |
|
50 | axios.Axios = Axios;
|
51 |
|
52 |
|
53 | axios.CanceledError = CanceledError;
|
54 | axios.CancelToken = CancelToken;
|
55 | axios.isCancel = isCancel;
|
56 | axios.VERSION = VERSION;
|
57 | axios.toFormData = toFormData;
|
58 |
|
59 |
|
60 | axios.AxiosError = AxiosError;
|
61 |
|
62 |
|
63 | axios.Cancel = axios.CanceledError;
|
64 |
|
65 |
|
66 | axios.all = function all(promises) {
|
67 | return Promise.all(promises);
|
68 | };
|
69 |
|
70 | axios.spread = spread;
|
71 |
|
72 |
|
73 | axios.isAxiosError = isAxiosError;
|
74 |
|
75 |
|
76 | axios.mergeConfig = mergeConfig;
|
77 |
|
78 | axios.AxiosHeaders = AxiosHeaders;
|
79 |
|
80 | axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
81 |
|
82 | axios.getAdapter = adapters.getAdapter;
|
83 |
|
84 | axios.HttpStatusCode = HttpStatusCode;
|
85 |
|
86 | axios.default = axios;
|
87 |
|
88 |
|
89 | export default axios
|