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

Actions must be plain objects while using PUT method

我尝试更新我的数据库对象,但我得到的只是这个错误 Actions must be plain objects. Use custom middleware for async actions

知道如何解决这个问题吗?

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 行是错误的。 dispatch(console.log())dispatch(undefined)一样,undefined绝对不是普通的动作对象