2 回答
TA贡献1833条经验 获得超4个赞
您正在尝试catch你的setState电话,而不是删除请求本身:
axios
.delete(apiVideoUrl, {})
.then((response: any) => {
this.setState({
adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)
})
}).catch(function(error) {
console.log(error);
});
TA贡献1155条经验 获得超0个赞
您将 .catch() 附加到 setState() 而不是 .then()
改变:
axios
.delete(apiVideoUrl, {})
.then((response: any) => {
this.setState({
adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)
}).catch(function(error) {
console.log(error);
});
到:
axios
.delete(apiVideoUrl, {})
.then((response:any) => {
this.setState({
adminhelpcard: adminhelpcard.filter((adminhelpcard: SingleAdminHelpCard) => adminhelpcard.id !== id)
})
}).catch(function(error) {
console.log(error);
});
添加回答
举报