mirror of https://github.com/buster-so/buster.git
filter out undefined query params
This commit is contained in:
parent
719134bae2
commit
eeb1c576b9
|
@ -10,7 +10,9 @@ export const prefetchGetDashboard = async (
|
||||||
|
|
||||||
await queryClient.prefetchQuery({
|
await queryClient.prefetchQuery({
|
||||||
...dashboardQueryKeys.dashboardGetDashboard(params.id, params.version_number),
|
...dashboardQueryKeys.dashboardGetDashboard(params.id, params.version_number),
|
||||||
queryFn: () => getDashboard_server(params)
|
queryFn: async () => {
|
||||||
|
return await getDashboard_server(params);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return queryClient;
|
return queryClient;
|
||||||
|
|
|
@ -20,7 +20,13 @@ export const serverFetch = async <T>(url: string, config: FetchConfig = {}): Pro
|
||||||
|
|
||||||
// Construct URL with query parameters
|
// Construct URL with query parameters
|
||||||
const queryParams = params
|
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}`;
|
const fullUrl = `${baseURL}${url}${queryParams}`;
|
||||||
|
|
Loading…
Reference in New Issue