fix: try-catch in prefetching function for correct building
This commit is contained in:
@ -17,14 +17,19 @@ import { combineProviders } from "@/utils/combineProviders";
|
||||
|
||||
async function prefetchData() {
|
||||
const queryClient = new QueryClient();
|
||||
const projectsData = await queryClient.fetchQuery(getProjectsOptions());
|
||||
|
||||
const firstProjectId = projectsData.items?.[0]?.id;
|
||||
if (!firstProjectId) return queryClient;
|
||||
try {
|
||||
const projectsData = await queryClient.fetchQuery(getProjectsOptions());
|
||||
|
||||
await queryClient.prefetchQuery(
|
||||
getBoardsOptions({ path: { projectId: firstProjectId } })
|
||||
);
|
||||
const firstProjectId = projectsData.items?.[0]?.id;
|
||||
if (!firstProjectId) return queryClient;
|
||||
|
||||
await queryClient.prefetchQuery(
|
||||
getBoardsOptions({ path: { projectId: firstProjectId } })
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn("Prefetch failed, continuing without data:", e);
|
||||
}
|
||||
|
||||
return queryClient;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user