点击收藏后,返回的列表中没有pin字段,刷新后依然没有
来源:9-3 用 useEditProject 编辑项目

慕UI6115286
2022-05-08
点击收藏后,返回的列表中没有pin字段,刷新后依然没有, 老师帮忙看一下
代码:
export const useEditProject = () => {
const client = useHttp();
const { run, ...asyncResult } = useAsync();
const mutate = (params: Partial<Project>) => {
return run(
client(`projects/${params.id}`, {
method: "PATCH",
data: params,
})
);
};
return {
mutate,
...asyncResult,
};
};
{
title: <Pin checked={true} disabled={true} />,
render(value, project) {
return (
<Pin
checked={project.pin}
onCheckedChange={(pin) => {
mutate({ id: project.id, pin });
}}
/>
);
},
},
写回答
1回答
-
慕哥5081857
2022-11-02
if(config.method.toUpperCase()==='GET'){ endPoint += `?${qs.stringify(data)}` }else{ config.body = JSON.stringify(data || {}) }
在自定义的http函数中,如果不为GET方法,那么body应该用JSON.stringify,而不是qs.stringify
00
相似问题