nsarrazin commited on
Commit
ff7f37c
·
1 Parent(s): 5f9165b

feat: move tool search to API client

Browse files
Files changed (1) hide show
  1. src/routes/tools/+page.ts +5 -11
src/routes/tools/+page.ts CHANGED
@@ -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";
4
 
5
  export const load = async ({ url, fetch }) => {
6
- const r = await fetch(`${base}/api/v2/tools/search?${url.searchParams.toString()}`);
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;
15
  };
 
1
+ import { throwOnError, useAPIClient } from "$lib/APIClient";
 
 
2
 
3
  export const load = async ({ url, fetch }) => {
4
+ const client = useAPIClient({ fetch });
5
 
6
+ return client.tools.search
7
+ .get({ query: Object.fromEntries(url.searchParams.entries()) })
8
+ .then(throwOnError);
 
 
 
 
9
  };