filter out undefined query params

This commit is contained in:
Nate Kelley 2025-04-08 09:38:14 -06:00
parent 719134bae2
commit eeb1c576b9
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 10 additions and 2 deletions

View File

@ -10,7 +10,9 @@ export const prefetchGetDashboard = async (
await queryClient.prefetchQuery({
...dashboardQueryKeys.dashboardGetDashboard(params.id, params.version_number),
queryFn: () => getDashboard_server(params)
queryFn: async () => {
return await getDashboard_server(params);
}
});
return queryClient;

View File

@ -20,7 +20,13 @@ export const serverFetch = async <T>(url: string, config: FetchConfig = {}): Pro
// Construct URL with query parameters
const queryParams = params
? `?${new URLSearchParams(Object.fromEntries(Object.entries(params).map(([k, v]) => [k, String(v)])))}`
? `?${new URLSearchParams(
Object.fromEntries(
Object.entries(params)
.filter(([_, v]) => v !== undefined)
.map(([k, v]) => [k, String(v)])
)
)}`
: '';
const fullUrl = `${baseURL}${url}${queryParams}`;