mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
Fixing #385 - Keep defaults local to instance
This commit is contained in:
+9
-5
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var defaults = require('./../defaults');
|
||||
var utils = require('./../utils');
|
||||
var InterceptorManager = require('./InterceptorManager');
|
||||
var dispatchRequest = require('./dispatchRequest');
|
||||
@@ -24,15 +23,20 @@ function Axios(instanceConfig) {
|
||||
* @param {Object} config The config specific for this request (merged with this.defaults)
|
||||
*/
|
||||
Axios.prototype.request = function request(config) {
|
||||
config = config || {};
|
||||
|
||||
/*eslint no-param-reassign:0*/
|
||||
// Allow for axios('example/url'[, config]) a la fetch API
|
||||
if (typeof config === 'string') {
|
||||
config = utils.merge({
|
||||
url: arguments[0]
|
||||
}, arguments[1]);
|
||||
config = arguments[1] || {};
|
||||
config.url = arguments[0];
|
||||
}
|
||||
|
||||
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
|
||||
if (!config.method) {
|
||||
config.method = 'get';
|
||||
}
|
||||
|
||||
config = utils.mergeConfig(this.defaults, config);
|
||||
config.method = config.method.toLowerCase();
|
||||
|
||||
// Hook up interceptors middleware
|
||||
|
||||
Reference in New Issue
Block a user