メモ
getStaticPropsが使えない
https://beta.nextjs.org/docs/data-fetching/fundamentals
headersを付ける
https://beta.nextjs.org/docs/data-fetching/fetching
https://document.microcms.io/manual/display-contents
async function getData() {
const res = await fetch('https://****.microCMS.com/endpoint',{
headers:{
"X-MICROCMS-API-KEY":"******************"
}
});
// The return value is *not* serialized
// You can return Date, Map, Set, etc.
// Recommendation: handle errors
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>;
}