提问人:Dreynaldis 提问时间:12/6/2022 最后编辑:Dreynaldis 更新时间:12/6/2022 访问量:34
在另一个操作中调用另一个函数
calling another function in another action
问:
import Axios from "axios";
export const ChangeTodoCount = (newCount) => {
return {
type: "CHANGE_TODO_COUNT",
payload: newCount,
};
};
export const FetchToDo = () => {
return (dispatch) => {
Axios.get("http://localhost:2000/todo").then((response) => {
dispatch({
type: "GET_TODO",
payload: response.data,
});
dispatch({
type: "CHANGE_TODO_COUNT",
payload: response.data.length,
});
});
};
};
export const DeleteItem = (id) => {
Axios.delete("http://localhost:2000/todo/" + id).then({ FetchToDo });
};
我正在尝试在运行后打电话.FetchToDo
DeleteItem
我需要如何添加才能做到这一点?
现在,当我单击删除按钮时,列表被删除,但我必须刷新页面才能重新获取列表。FetchToDo
答:
0赞
sandeep sharma
12/6/2022
#1
`export const DeleteItem = (id) => {Axios.delete("http://localhost:2000/todo/" + id).then(()=>FetchToDo())};`
评论
Axios.delete("http://localhost:2000/todo/" + id).then(() => FetchToDo());