From 6f4f375e945987176bbf9d904e1b8a7b47a22ac5 Mon Sep 17 00:00:00 2001 From: Xianming Zhong Date: Sat, 12 Sep 2020 16:38:35 +0800 Subject: [PATCH] fix axios.delete ignores config.data --- lib/core/Axios.js | 3 ++- test/specs/requests.spec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/core/Axios.js b/lib/core/Axios.js index 1f65a81ec7..c28c413ad3 100644 --- a/lib/core/Axios.js +++ b/lib/core/Axios.js @@ -75,7 +75,8 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData Axios.prototype[method] = function(url, config) { return this.request(mergeConfig(config || {}, { method: method, - url: url + url: url, + data: (config || {}).data })); }; }); diff --git a/test/specs/requests.spec.js b/test/specs/requests.spec.js index 3e6331892c..f27ef88adc 100644 --- a/test/specs/requests.spec.js +++ b/test/specs/requests.spec.js @@ -43,6 +43,17 @@ describe('requests', function () { }); }); + it('should allow data', function (done) { + axios.delete('/foo', { + data: { foo: 'bar' } + }); + + getAjaxRequest().then(function (request) { + expect(request.params).toBe(JSON.stringify({ foo: 'bar' })); + done(); + }); + }); + it('should make an http request', function (done) { axios('/foo');