0
Follow
2
View

How to get json data from api dynamics route to getStaticPaths

why80038003 注册会员
2023-01-25 11:50
// pages/posts/[id].js

// Generates `/posts/1` and `/posts/2`
export async function getStaticPaths() {
  return {
    paths: [{ params: { id: '1' } }, { params: { id: '2' } }],
    fallback: false, // can also be true or 'blocking'
  }
}

// `getStaticPaths` requires using `getStaticProps`
export async function getStaticProps(context) {
  return {
    // Passed to the page component as props
    props: { post: {} },
  }
}

export default function Post({ post }) {
  // Render post...
}

Reference Link https://nextjs.org/docs/basic-features/data-fetching/get-static-paths

About the Author

Question Info

Publish Time
2023-01-25 11:50
Update Time
2023-01-25 11:50