Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghao1993 committed Sep 9, 2024
1 parent 90d177b commit a3537df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/api/blog/detail/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function GET(request: Request) {
);
}
return responseHandler(res);
} catch (error) {
} catch (error: any) {
console.error("GET 请求错误:", error);
return responseHandler(
null,
Expand Down Expand Up @@ -89,7 +89,7 @@ export async function POST(req: Request, res: Response) {
data: { likes_count },
});
return responseHandler(updatePost);
} catch (error) {
} catch (error: any) {
console.error("POST 请求错误:", error);
return responseHandler(
null,
Expand Down
12 changes: 4 additions & 8 deletions components/LikeAndCollect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ import { useEffect, useState } from "react";
export default function LikeAndCollect(data: { blogKey: string }) {
const [detail, setDetail] = useState<PostTypes.PostDetail>();

const getData = async () => {
const res = await get<PostTypes.PostDetail>("blog/detail", {
useEffect(() => {
get<PostTypes.PostDetail>("blog/detail", {
key: data.blogKey,
}).then((res) => {
setDetail(res);
});

setDetail(res);
};

useEffect(() => {
getData();
}, [data.blogKey]);
const session = useSession();

Expand Down

0 comments on commit a3537df

Please sign in to comment.