我正在尝试编写此函数:
export default function generateServerSideProps<SearchResponse>(mode: Mode) {
return async ({ query }: GetServerSidePropsContext) => {
const { query: searchQuery } = query;
const makePath = buildMakePathFromMode(mode, searchQuery, filters);
return {
props: {
mode,
searchQuery,
filters,
initialData: await firstPage<SearchResponse>(makePath),
},
};
}
}
firstPage
调用 api 并接收响应。我想传递响应类型,但是 typescript 在 searchReponse
行中的 initialData: await firstPage<SearchResponse>(makePath)
上看到错误。
任何建议将不胜感激。