React native 使用PUT方法时,操作必须是普通对象

React native 使用PUT方法时,操作必须是普通对象,react-native,redux,redux-thunk,React Native,Redux,Redux Thunk,我试图更新我的DB对象,但我得到的只是这个错误操作必须是普通对象。将自定义中间件用于异步操作 你知道我该怎么解决这个问题吗 export function updateUserData(firstName, lastName) { return function (dispatch, getState) { const state = getState(); const { user_id, token } = state.auth; return axios.put

我试图更新我的DB对象,但我得到的只是这个错误
操作必须是普通对象。将自定义中间件用于异步操作

你知道我该怎么解决这个问题吗

export function updateUserData(firstName, lastName) {
  return function (dispatch, getState) {
    const state = getState();
    const { user_id, token } = state.auth;
    return axios.put(USER_DATA(user_id), { firstName, lastName }, {
      headers: { authorization: token }
    }).then((response) => {
      dispatch(console.log(response.data));
    }).catch((err) => {
      dispatch(console.log("Couldn't update user data."));
    });
  };
}

您的
调度
行错误
dispatch(console.log())
dispatch(undefined)
相同,而且
undefined
绝对不是简单的操作对象。

错误说明了一切,是否使用redux thunk作为中间件?你需要使用它,这样你就可以与reduxYes进行异步操作。我正在使用Redux Thunk,正如你所看到的,我在帖子中也做了标记。我还使用了
getState()
,这是thunk函数。正如我所说,这是唯一一个给我这个错误的函数,我试图理解我做错了什么