MCPcopy
hub / github.com/axios/axios / createInstance

Function createInstance

lib/axios.js:28–44  ·  view source on GitHub ↗

* Create an instance of Axios * * @param {Object} defaultConfig The default config for the instance * * @returns {Axios} A new instance of Axios

(defaultConfig)

Source from the content-addressed store, hash-verified

26 * @returns {Axios} A new instance of Axios
27 */
28function 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
47const axios = createInstance(defaults);

Callers 1

axios.jsFile · 0.85

Calls 2

bindFunction · 0.85
mergeConfigFunction · 0.85

Tested by

no test coverage detected