7️데이터 페칭
서버에서 fetch
fetchasync function getData() {
const res = await fetch('https://api.example.com/...')
// 직렬화되지 않기 때문에 데이터 타입을 바로 사용할 수 있습니다.
if (!res.ok) {
// 에러를 던지면 가장 가까이 있는 error.tsx 파일에 걸립니다.
throw new Error('Failed to fetch data')
}
return res.json()
}
export default async function Page() {
const data = await getData()
return <main></main>
}데이터 캐싱(Caching)
데이터 재검증(Revalidating)
시간 기반 재검증(Time-based revalidtaion)
온디맨드 재검증(On-demand revalidtaion)
참고 자료
Last updated


