7.1 게시글 CRUD API 및 페이지 연동 o
This commit is contained in:
15
src/app/posts/[id]/page.tsx
Normal file
15
src/app/posts/[id]/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export default async function PostDetail({ params }: { params: { id: string } }) {
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL ?? ""}/api/posts/${params.id}`, { cache: "no-store" });
|
||||
if (!res.ok) return notFound();
|
||||
const { post } = await res.json();
|
||||
return (
|
||||
<div>
|
||||
<h1>{post.title}</h1>
|
||||
<p style={{ whiteSpace: "pre-wrap" }}>{post.content}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user