向Axios发出请求

编程入门 行业动态 更新时间:2024-10-26 21:19:33
本文介绍了向Axios发出请求| React,Redux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想向Axios发出放置请求,到目前为止,我已将此操作包含在内:

I want to make a put request with Axios and I got this inside of my action so far:

export function updateSettings(item) { return dispatch => { console.log(item) return axios.put(`/locks`).then(response => { console.log(response) }) } }

当我console.log item时,我可以看到我在该对象内的输入框中键入的所有内容,但是后来我得到404.我知道我拥有该URI.有人知道如何解决此问题吗?

When I console.log item I can see all of things I've typed in my input boxes inside of that object, but later I get 404. I know that I have that URI. Does anyone know how to troubleshoot this problem?

推荐答案

放置响应将需要一个与之一起发送的对象.投放的正确axios是这样:

a put response will need an object to send with. the correct axios for put is this:

export function updateSettings(item) { return dispatch => { console.log(item) return axios.put(`/locks`, item).then(response => { console.log(response) }) } }

这很可能是您收到错误的原因,因为用于PUT的对象未定义.

this is most likely why you get the error because the object to PUT with is undefined.

您可以在下面的链接上观看此列表,以了解如何使用axios发出正确的请求. Axios请求方法

You can watch this list on the link below, to how to make the correct requests with axios. Axios request methods

更多推荐

向Axios发出请求

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

发布评论

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

>www.elefans.com

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