Axios 删除带有正文和标题的请求?

编程入门 行业动态 更新时间:2024-10-28 14:29:03
本文介绍了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 删除带有正文和标题的请求?

本文发布于:2023-10-09 16:59:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标题   正文   Axios

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!