diff --git a/client/src/components/Grid/configs/visualizationsPublished.ts b/client/src/components/Grid/configs/visualizationsPublished.ts index 6ad67df8f007..1c7c916da2dc 100644 --- a/client/src/components/Grid/configs/visualizationsPublished.ts +++ b/client/src/components/Grid/configs/visualizationsPublished.ts @@ -1,16 +1,12 @@ import { faEye } from "@fortawesome/free-solid-svg-icons"; -import { fetcher } from "@/api/schema"; +import { client } from "@/api"; import Filtering, { contains, expandNameTag, type ValidFilter } from "@/utils/filtering"; import { withPrefix } from "@/utils/redirect"; +import { rethrowSimple } from "@/utils/simple-error"; import { type FieldArray, type GridConfig } from "./types"; -/** - * Api endpoint handlers - */ -const getVisualizations = fetcher.path("/api/visualizations").method("get").create(); - /** * Local types */ @@ -21,17 +17,26 @@ type VisualizationEntry = Record; * Request and return data from server */ async function getData(offset: number, limit: number, search: string, sort_by: string, sort_desc: boolean) { - const { data, headers } = await getVisualizations({ - limit, - offset, - search, - sort_by: sort_by as SortKeyLiteral, - sort_desc, - show_own: false, - show_published: true, - show_shared: true, + const { response, data, error } = await client.GET("/api/visualizations", { + params: { + query: { + limit, + offset, + search, + sort_by: sort_by as SortKeyLiteral, + sort_desc, + show_own: false, + show_published: true, + show_shared: true, + }, + }, }); - const totalMatches = parseInt(headers.get("total_matches") ?? "0"); + + if (error) { + rethrowSimple(error); + } + + const totalMatches = parseInt(response.headers.get("total_matches") ?? "0"); return [data, totalMatches]; }