setTimeout(response, 5000)) const response = await fetch(URL) const json = await response.json() return json } export default async function HomePage() { const movies = await getMovies() return (
{JSON.stringify(movies)}
) }"> setTimeout(response, 5000)) const response = await fetch(URL) const json = await response.json() return json } export default async function HomePage() { const movies = await getMovies() return (
{JSON.stringify(movies)}
) }"> setTimeout(response, 5000)) const response = await fetch(URL) const json = await response.json() return json } export default async function HomePage() { const movies = await getMovies() return (
{JSON.stringify(movies)}
) }">
export const metadata = {
    title: "Home"
}

const URL = "<https://nomad-movies.nomadcoders.workers.dev/movies>"

async function getMovies() {
    await new Promise((response) => setTimeout(response, 5000))
    const response = await fetch(URL)
    const json = await response.json()
    return json
}

export default async function HomePage() {
    const movies = await getMovies()
    return (
        <div>
            {JSON.stringify(movies)}
        </div>
    )
}
  1. 코드 정리 및 변수 설정
  2. 메타데이터와 데이터 페칭 함수 작성
  3. 컴포넌트 수정
  4. Next.js의 데이터 캐싱 기능 설명
  5. 로딩 상태 처리
  6. 로딩 상태 개선 필요성