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

Delete请求时data没有正确发送 #3292

Closed
qmhc opened this issue Sep 17, 2020 · 7 comments
Closed

Delete请求时data没有正确发送 #3292

qmhc opened this issue Sep 17, 2020 · 7 comments

Comments

@qmhc
Copy link

qmhc commented Sep 17, 2020

Describe the bug

在发送 delete 请求时,传入 data

在 0.19.2 版本的时候,该 data 是能正确发送,并被后端 @RequestBody 正确解析的,在 0.20.0 版本后该 data 没有被正确发送,进而会导致数据接收不到或者发生 400 错误

To Reproduce

import Axios from 'axios'

Axios.delete('/api', {
  headers: {
      'Content-Type': 'application/json'
  },
  data: jsonData
})

Expected behavior

options.data 的数据能被正确发送至后端

Environment

  • Axios Version [0.20.0]
  • Browser [Chrome]

Additional context/Screenshots

image

@kasper
Copy link

kasper commented Sep 17, 2020

I’m seeing the same issue. The data is not attached to DELETE requests.

@Nicholaiii
Copy link

The delete instance method does not take data. Use request instead:

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

@tobias-grasse
Copy link

tobias-grasse commented Sep 17, 2020

Also hitting this after updating to 0.20.0.

@Nicholaiii Please note that @qmhc 's code example does not use the positional data argument (which would indeed not be in the delete signature), but the data config option – which should work for DELETE requests as well, per the docs. #2887 explicitly added this to the docs, so its misleading at least.

EDIT: Well, like others in this thread I completely overlooked the pinned issue which confirms it's a regression in 0.20.0, and #3282 fixes the issue. Duplicate of #3220

@Nicholaiii
Copy link

Also hitting this after updating to 0.20.0.

@Nicholaiii Please note that @qmhc 's code example does not use the positional data argument (which would indeed not be in the delete signature), but the data config option – which should work for DELETE requests as well, per the docs. #2887 explicitly added this to the docs, so its misleading at least.

EDIT: Well, like others in this thread I completely overlooked the pinned issue which confirms it's a regression in 0.20.0, and #3282 fixes the issue. Duplicate of #3220

I see. Either way, the request option fixes the issue untill the PR is merged.

@chinesedfan
Copy link
Collaborator

Duplicate of #3220. Sorry for the breaking, and hope #3282 can be merged and released soon.

@jasonsaayman
Copy link
Member

Hi,

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

Thanks

@qmhc
Copy link
Author

qmhc commented Oct 24, 2020

@jasonsaayman
Now is working well.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants