【发布时间】:2021-03-18 22:34:38
【问题描述】:
我想将上一页中的projectID(/projects) 传递给 (/project/[projectName])。因此,为了获取项目详细信息,我必须使用 projectID. 触发 API 端点
从上一页传递projectID的正确方法是什么,以及如何在getServersideProps方法中访问它。
在/project/[projectName] 页面中,
export async function getServerSideProps(){
// Here i want to access the projectID sent from the previous page
const data = await fetchData();
return {
props: data,
};
}
Query/param prop 可以访问 projectName 但不能访问 projectID。
【问题讨论】:
标签: reactjs next.js server-side-rendering