* Create an instance of Axios * * @param {Object} defaultConfig The default config for the instance * * @returns {Axios} A new instance of Axios
(defaultConfig)
| 26 | * @returns {Axios} A new instance of Axios |
| 27 | */ |
| 28 | function createInstance(defaultConfig) { |
| 29 | const context = new Axios(defaultConfig); |
| 30 | const instance = bind(Axios.prototype.request, context); |
| 31 | |
| 32 | // Copy axios.prototype to instance |
| 33 | utils.extend(instance, Axios.prototype, context, { allOwnKeys: true }); |
| 34 | |
| 35 | // Copy context to instance |
| 36 | utils.extend(instance, context, null, { allOwnKeys: true }); |
| 37 | |
| 38 | // Factory for creating new instances |
| 39 | instance.create = function create(instanceConfig) { |
| 40 | return createInstance(mergeConfig(defaultConfig, instanceConfig)); |
| 41 | }; |
| 42 | |
| 43 | return instance; |
| 44 | } |
| 45 | |
| 46 | // Create the default instance to be exported |
| 47 | const axios = createInstance(defaults); |
no test coverage detected