Html이나 css버튼을 클릭하였을 때 나오는 읽기 기능을 구현해보겠습니다.
app/read/[id]/page.js를 수정해보겠습니다.
export default async function Read(props) {
const resp = await fetch(`http://localhost:9999/topics/${props.params.id}`);
//id값을 Url에 반영하여 데이터를 가져온다.
const topic = await resp.json();
return (
<>
<h2>{topic.title}</h2>
{topic.body}
</>
);
}