向Axios发出请求| React,Redux [英] Put request with Axios | React, Redux

查看:228
本文介绍了向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发出请求| React,Redux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆