【发布时间】:2020-07-12 13:31:39
【问题描述】:
我正在使用 React、Typescript、Effector、FetchAPI 等开发前端应用程序。 我做了一个效果器效果来删除我后端的一个项目:
export const deleteItemFX = createEffect({
handler: (id: string) => {
return fetch(itemUrl + id, {
method: "DELETE",
});
}
})
现在在我的 React 组件中,我根据文档导入效果并为其“finally”事件添加订阅者:
deleteItemFX.finally.watch(({params, status, result}) => {
console.log('finally.watch called');
if (result.ok) {
result.json().then(() => {
message.success(t("delete_item.success"));
})
}
});
由于以下类型错误,我的代码无法编译:
Property 'result' does not exist on type '{ status: "done"; params: string; result: Response; } | { status: "fail"; params: string; error: Error; }'. TS2339
有谁知道我可以做些什么来在“finally.watch”函数中获取处理程序的“结果”?
【问题讨论】:
标签: typescript typeerror typescript-typings effector