Next.js Discord

Discord Forum

For some reason I am getting a 200 response when fetching json file but no data with it.

Unanswered
Rufous-backed Robin posted this in #help-forum
Open in Discord
Rufous-backed RobinOP
const ProductPage = async({params})=>{

//discord comment, process.env.NEXT_PUBLIC_SITE_URL = http://localhost:3000

  const res = await fetch(`${process.env.NEXT_PUBLIC_SITE_URL}/data/productList.json`, {
    cache: "force-cache"
  })

console.log(res)

  return (
    // {products.map((product) => <ProductCard product={product}/>)}
    <div className={styles.ProductsPage}></div>
  )
}

1 Reply

Milkfish
You have to await the json too.

await res.json()