2
0
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:
Martti Laine
2018-03-01 23:53:38 +02:00
parent 604e8dd860
commit 5bfd2ea9f6
5 changed files with 87 additions and 9 deletions
+9 -5
View File
@@ -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