本文介绍了Axios 删除带有正文和标题的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在用 ReactJS 编程时使用 Axios,我假装向我的服务器发送 DELETE 请求.
I'm using Axios while programing in ReactJS and I pretend to send a DELETE request to my server.
为此,我需要标题:
headers: { 'Authorization': ... }和身体是由
var payload = { "username": .. }我一直在网上搜索,只发现 DELETE 方法需要一个参数"并且不接受数据".
I've been searching in the inter webs and only found that the DELETE method requires a "param" and accepts no "data".
我一直在尝试像这样发送它:
I've been trying to send it like so:
axios.delete(URL, payload, header);甚至
axios.delete(URL, {params: payload}, header);但似乎没有任何效果...
But nothing seems to work...
有人可以告诉我是否可以(我认为是)发送带有标头和正文的 DELETE 请求以及如何发送?
Can someone tell me if its possible (I presume it is) to send a DELETE request with both headers and body and how to do so ?
先谢谢你!
推荐答案所以经过多次尝试,我发现它有效.
So after a number of tries, I found it working.
请按照顺序很重要,否则不行
axios.delete(URL, { headers: { Authorization: authorizationToken }, data: { source: source } });更多推荐
Axios 删除带有正文和标题的请求?
发布评论