client: catch error

This commit is contained in:
fantasticit 2022-06-03 04:26:55 +08:00
parent 86755013b4
commit cd071ccae1
1 changed files with 13 additions and 9 deletions

View File

@ -14,15 +14,19 @@ export async function serverPrefetcher(ctx: NextPageContext, actions: PrefetchAc
return {}; return {};
} }
const queryClient = new QueryClient(); try {
const queryClient = new QueryClient();
await Promise.all( await Promise.all(
actions.map((action) => { actions.map((action) => {
return queryClient.prefetchQuery(action.url, () => action.action(cookie)); return queryClient.prefetchQuery(action.url, () => action.action(cookie));
}) })
); );
return { return {
dehydratedState: dehydrate(queryClient), dehydratedState: dehydrate(queryClient),
}; };
} catch (err) {
return {};
}
} }