client: catch error

pull/64/head
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 {};
}
const queryClient = new QueryClient();
try {
const queryClient = new QueryClient();
await Promise.all(
actions.map((action) => {
return queryClient.prefetchQuery(action.url, () => action.action(cookie));
})
);
await Promise.all(
actions.map((action) => {
return queryClient.prefetchQuery(action.url, () => action.action(cookie));
})
);
return {
dehydratedState: dehydrate(queryClient),
};
return {
dehydratedState: dehydrate(queryClient),
};
} catch (err) {
return {};
}
}