Skip to content

Commit

Permalink
Fixing set config.method after mergeConfig for Axios.prototype.requ…
Browse files Browse the repository at this point in the history
…est (axios#2383)

Inside Axios.prototype.request function, It's forced to set
method to 'get' after `mergeConfig` if config.method exists, which makes the defaults.method not effective.
  • Loading branch information
bushuai authored and genie-youn committed Sep 27, 2019
1 parent 1cc39f5 commit fecdd07
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/core/Axios.js
Expand Up @@ -35,7 +35,15 @@ Axios.prototype.request = function request(config) {
}

config = mergeConfig(this.defaults, config);
config.method = config.method ? config.method.toLowerCase() : 'get';

// Set config.method
if (config.method) {
config.method = config.method.toLowerCase();
} else if (this.defaults.method) {
config.method = this.defaults.method.toLowerCase();
} else {
config.method = 'get';
}

// Hook up interceptors middleware
var chain = [dispatchRequest, undefined];
Expand Down

0 comments on commit fecdd07

Please sign in to comment.