LoginSignup
1
0

More than 1 year has passed since last update.

microCMSとNext13

Posted at

メモ
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>;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0