Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axios does not use data from config when making DELETE request #3220

Closed
vadimka123 opened this issue Aug 21, 2020 · 19 comments · Fixed by #3282
Closed

Axios does not use data from config when making DELETE request #3220

vadimka123 opened this issue Aug 21, 2020 · 19 comments · Fixed by #3282
Projects
Milestone

Comments

@vadimka123
Copy link

vadimka123 commented Aug 21, 2020

Describe the bug

Axios last version (0.20.0) does not use data from config when making DELETE request. In 0.19.2 it's working fine

To Reproduce

axios.delete("...", { 
    data: { ids: [...] },
}).then(response => {
    ...
}).catch(error => {
    ...
});

Expected behavior

Axios send request data from config when making DELETE request

Environment

  • Axios Version 0.20.0
  • Browser Chrome
  • Browser Version 84.0.4147.125
  • Node.js Version 12.18.3
  • OS: Linux Mint
  • Additional Library Versions React 16.13.1

Additional context/Screenshots

None

@vadimka123 vadimka123 changed the title Axios does not use data from comfig when making DELETE request Axios does not use data from config when making DELETE request Aug 21, 2020
@Theofilos-Chamalis
Copy link

I see the same behavior for DELETE requests as well in my React Web Application

@SSANSH
Copy link

SSANSH commented Aug 21, 2020

+1: my contracts failed with latest version of axios using delete verb with body request (in case of bulk delete).

@chinesedfan
Copy link
Collaborator

Tested in runkit and confirmed. It is really a breaking change.

version axios axios.delete
0.18.0 has data has data
0.19.0/1/2 has data has data
0.20.0 has data no data

The reason is that mergeConfig always selects the next data. For other aliases with data(like post/put/patch), it is reasonable. But for aliases without data, the original utils.merge is better. We should fix it in the next release with some tests.

// lib/core/Axios.js
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  /*eslint func-names:0*/
  Axios.prototype[method] = function(url, config) {
    return this.request(mergeConfig(config || {}, {
      method: method,
      url: url
    }));
  };
});

utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  /*eslint func-names:0*/
  Axios.prototype[method] = function(url, data, config) {
    return this.request(mergeConfig(config || {}, {
      method: method,
      url: url,
      data: data
    }));
  };
});

@agnjunio
Copy link

After taking a look at the history, found out that this issue was introduced in 0d69a79
Should we revert the mergeConfig in favor of utils.merge or try to adapt the mergeConfig to have a similar behavior?

@ggaabe
Copy link

ggaabe commented Aug 27, 2020

I'm getting this same issue. It took a long time to figure out it was an issue with the package, this is probably a relatively urgent fix.

@blixt
Copy link

blixt commented Sep 1, 2020

This broke multiple endpoints in subtle ways for us when updating Axios and took some time to identify. I hope for the sake of other companies that this issue is resolved quickly.

szainmehdi added a commit to nawhas/nawhas that referenced this issue Sep 2, 2020
@14glwu
Copy link

14glwu commented Sep 3, 2020

I also meet this problem

AxelTerizaki pushed a commit to karaokemugen/karaokemugen-app that referenced this issue Sep 3, 2020
AxelTerizaki pushed a commit to karaokemugen/karaokemugen-app that referenced this issue Sep 3, 2020
@ogard
Copy link

ogard commented Sep 4, 2020

Same from my side: when updating from v0.19.2 to v0.20.0, data argument is not forwarded to network DELETE request

@nohanna
Copy link

nohanna commented Sep 4, 2020

Same problem for me, I had to revert my package-lock.json to understand what was going on.

@zhangyy62
Copy link

Not use data is recommend by delete request in Restful API. But I think Axios shouldn't be forced to disable

@wopian
Copy link

wopian commented Sep 6, 2020

@sparkxxxxxx DELETE with a body (data) is part of the HTTP spec.

https://tools.ietf.org/html/rfc7231#section-4.3.5

@tim-field
Copy link

tim-field commented Sep 8, 2020

FYI the following is a work around until this is fixed

axios.request({
      ...config,
      method: 'delete',
      url,
      data
})

@zhangyy62
Copy link

@wopian I'm with you.

@chinesedfan
Copy link
Collaborator

Kindly invite someone to test with #3282. Hope it solves the problem.

@wopian
Copy link

wopian commented Sep 12, 2020

@chinesedfan I built #3282 from source and patched it into node_modules and our 6 failing DELETE tests that mock endpoint responses with data now pass 👍

nohanna added a commit to nohanna/swingify that referenced this issue Sep 16, 2020
@dball
Copy link

dball commented Sep 28, 2020

This seems worthy of cutting 0.20.1 to release sooner than later.

@jasonsaayman
Copy link
Member

Hi,

Version 0.21.0 has been released 🎉 please use that and let us know if that solves your issue.

Thanks

@jasonsaayman jasonsaayman added this to the v0.21.0 milestone Oct 23, 2020
@jasonsaayman jasonsaayman added this to To do in v0.21.0 via automation Oct 23, 2020
@jasonsaayman jasonsaayman moved this from To do to Done in v0.21.0 Oct 23, 2020
@vadimka123
Copy link
Author

Hi, @jasonsaayman

Tested and issue is fixed

Thanks

@dmbarry86
Copy link

Hi,

Version 0.21.0 has been released 🎉 please use that and let us know if that solves your issue.

Thanks

Can confirm issue is fixed for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v0.21.0
  
Done
Development

Successfully merging a pull request may close this issue.