We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17b22a8 commit c713e50Copy full SHA for c713e50
1 file changed
src/routes/tools/+page.ts
@@ -1,15 +1,9 @@
1
-import { base } from "$app/paths";
2
-import type { GETToolsSearchResponse } from "$api/routes/groups/tools";
3
-import { error } from "@sveltejs/kit";
+import { throwOnError, useAPIClient } from "$lib/APIClient";
4
5
export const load = async ({ url, fetch }) => {
6
- const r = await fetch(`${base}/api/v2/tools/search?${url.searchParams.toString()}`);
+ const client = useAPIClient({ fetch });
7
8
- if (!r.ok) {
9
- throw error(r.status, "Failed to fetch tools");
10
- }
11
-
12
- const data = (await r.json()) as GETToolsSearchResponse;
13
14
- return data;
+ return client.tools.search
+ .get({ query: Object.fromEntries(url.searchParams.entries()) })
+ .then(throwOnError);
15
};
0 commit comments