From fa3673710ea6bb3f351b4790bb17998d2f01f342 Mon Sep 17 00:00:00 2001 From: Xianming Zhong Date: Thu, 1 Oct 2020 15:46:32 +0800 Subject: [PATCH] fix axios.delete ignores config.data (#3282) Co-authored-by: Jay --- 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');