diff --git a/client/src/components/Grid/configs/pagesPublished.ts b/client/src/components/Grid/configs/pagesPublished.ts index db8d08239ca1..11fa4ef19009 100644 --- a/client/src/components/Grid/configs/pagesPublished.ts +++ b/client/src/components/Grid/configs/pagesPublished.ts @@ -1,18 +1,14 @@ import { faEye, faPlus } from "@fortawesome/free-solid-svg-icons"; import { useEventBus } from "@vueuse/core"; -import { fetcher } from "@/api/schema"; +import { client } from "@/api"; import Filtering, { contains, type ValidFilter } from "@/utils/filtering"; +import { rethrowSimple } from "@/utils/simple-error"; import { type ActionArray, type FieldArray, type GridConfig } from "./types"; const { emit } = useEventBus("grid-router-push"); -/** - * Api endpoint handlers - */ -const getPages = fetcher.path("/api/pages").method("get").create(); - /** * Local types */ @@ -23,17 +19,26 @@ type PageEntry = 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 getPages({ - 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/pages", { + 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]; }