nextjs Data List

/ 목차 /
- NEXT.JS 데이터 가져오기
NEXT.JS 데이터 가져오기
- fetch함수를 사용해서 API 데이터를 가져오는 부분입니다 이부분이 중요한 이유는 DB데이터를 가져와서 화면에 보여주는 역활을 하기 때문입니다.code async function getData() { const res = await fetch('https://api.datacafe.kr/...') // The return value is *not* serialized // You can return Date, Map, Set, etc. if (!res.ok) { // This will activate the closest `error.js` Error Boundary throw new Error('Failed to fetch data') } return res.json() } export default async function Page() { const data = await getData() return <main></main> }
Comment