Skip to content

Commit 3579da4

Browse files
authored
Merge pull request axios#930 from luciy/master
Convert the method parameter to lowercase
2 parents d1278df + e4e3212 commit 3579da4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/core/Axios.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Axios.prototype.request = function request(config) {
3535
}
3636

3737
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
38+
config.method = config.method.toLowerCase();
3839

3940
// Support baseURL config
4041
if (config.baseURL && !isAbsoluteURL(config.url)) {

test/specs/requests.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ describe('requests', function () {
1717
});
1818
});
1919

20+
it('should treat method value as lowercase string', function (done) {
21+
axios({
22+
url: '/foo',
23+
method: 'POST'
24+
}).then(function (response) {
25+
expect(response.config.method).toBe('post');
26+
done();
27+
});
28+
29+
getAjaxRequest().then(function (request) {
30+
request.respondWith({
31+
status: 200
32+
});
33+
});
34+
});
35+
2036
it('should allow string arg as url, and config arg', function (done) {
2137
axios.post('/foo');
2238

0 commit comments

Comments
 (0)