【发布时间】:2020-12-08 16:54:25
【问题描述】:
//reducer.js
const initialState = {
students:[]
}
const reducer = (state = initialState, action) =>{
//load... data
const allStudents = [...state.students];
//check... case
switch (action.type) {
case 'GET_STUDENT_LISTS':
const loadStudent = {
...state,
students: action.payload
}
return loadStudent
default:
break;
}
//end switch case
return state;
}
export default reducer;
我的项目有一些问题。我想将 app.js 中的 student[] 发送到 reducer.js 中的 student[]。 我通过 node app.js 和 localhost:3000/api/students 测试。它可以显示数组。 但是 reducer.js 中的 student[] 没有得到它。我怎么能得到它。 请帮帮我。
【问题讨论】:
-
我投票结束这个问题,因为这个问题没有得到最好的解释,详细信息被添加为答案。
-
抱歉,这是我第一次使用这个。
-
请添加更多信息。