From 735f99bd3d8bf08efe8972bb47da485557d3efea Mon Sep 17 00:00:00 2001 From: bushuai Date: Fri, 30 Aug 2019 10:31:44 +0800 Subject: [PATCH] Fixing set `config.method` after mergeConfig for Axios.prototype.request 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. --- lib/core/Axios.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/Axios.js b/lib/core/Axios.js index 811cb36498..fb34aced66 100644 --- a/lib/core/Axios.js +++ b/lib/core/Axios.js @@ -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];