1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 'use strict';
- var utils = require('./utils');
- var bind = require('./helpers/bind');
- var Axios = require('./core/Axios');
- /**
- * Create an instance of Axios
- *
- * @param {Object} defaultConfig The default config for the instance
- * @return {Axios} A new instance of Axios
- */
- function createInstance(defaultConfig) {
- var context = new Axios(defaultConfig);
- var instance = bind(Axios.prototype.request, context);
- // Copy axios.prototype to instance
- utils.extend(instance, Axios.prototype, context);
- // Copy context to instance
- utils.extend(instance, context);
- return instance;
- }
- // Create the default instance to be exported
- var axios = module.exports = createInstance();
- // Expose Axios class to allow class inheritance
- axios.Axios = Axios;
- // Factory for creating new instances
- axios.create = function create(defaultConfig) {
- return createInstance(defaultConfig);
- };
- // Expose all/spread
- axios.all = function all(promises) {
- return Promise.all(promises);
- };
- axios.spread = require('./helpers/spread');
|