[英]I GET array from API but when i try show it in the table it show me empty array (noob ReactJs)
I created a Be api I that exist a Get request to get all the tasks from this API,我创建了一个 Be api 我存在一个 Get 请求以从这个 API 获取所有任务,
{
"tasks": [
{
"_id": "5f0b19c11f072e0984459ff5",
"title": "some Edited random stuff ",
"description": "some Edited random stuff",
"creater": "vladi",
"__v": 0
},
{
"_id": "5f0b19d71f072e0984459ff6",
"title": "vladi task ",
"description": "vladi description",
"creater": "vladi",
"__v": 0
} ]
in my TaskReducer i make it在我的 TaskReducer 中,我做到了
tasks: {
tasks: []
},
now in my fronted page i ask to see it all in a table现在在我的首页中,我要求在表格中查看所有内容
<tbody>
{this.props.tasks.tasks.map((task, taskID) =>
<tr key={taskID}>
<th scope="row" > 2{task.title}</th>
<td >3{task.description}</td>
<td >4{task.creater}</td>
<td >5{task.dateCreated}</td>
<td >
<span className="pointer" onClick={() => this.handlerClickDeleteTask(task.taskID)}>delete </span>
<span className="pointer" onClick={() => this.handlerClickViewTask(task.taskID)}>edit </span>
<span className="pointer" onClick={() => this.handlerClickEditTask(task.taskID)}>view </span>
</td>
</tr>
)}
</tbody>
but when i open the table it look empty (even not showing the numbers there) this is the link to the repository if someone have idea or think need more https://github.com/VladiKonovalov/Fronted/blob/master/src/containers/Tasks.js但是当我打开表格时它看起来是空的(甚至没有显示那里的数字)如果有人有想法或认为需要更多https://github.com/VladiKonovalov/Fronted/blob/master/src/ ,这是存储库的链接容器/Tasks.js
under usersActions.js
file you are setting users instead of tasks.在
usersActions.js
文件下,您正在设置用户而不是任务。
case "SET_TASKS":
state = { ...state, users: action.payload }
break;
default:
it should be like:它应该是这样的:
case "SET_TASKS":
state = { ...state, tasks: action.payload }
break;
default:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.