可能简单一些...我知道我缺少一些... 我的用户ID返回键而不是值。这是一个测试,以查看api调用返回了什么。
actionCreator
import * as actions from "./types";
import axios from "axios";
export const userDashBoard = userId => dispatch => {
axios.post("/api/authpages/dashboard", userId).then(user => {
dispatch({
type: actions.GET_PROFILE,
payload: user.data
});
});
};
减速器
import { GET_PROFILE, CLEAR_PROFILE } from "../actions/types";
const INITIAL = {};
export default (state = INITIAL, action) => {
switch (action.type) {
case GET_PROFILE:
return { ...state, profileData: action.payload };
case CLEAR_PROFILE:
return { ...state, profile: "" };
default:
return state;
}
};
API
router.post("/dashboard", (req, res) => {
res.json(req.body);
});
我从Redux的收益中得到了什么
This should be an image of the redux result
我知道api应该返回req.body.userId,但是当我这样做时我什么也没得到。我得到回复的唯一方法是只致电req.body ...
任何帮助都会很棒...谢谢!