Skip to content

Commit c713e50

Browse files
committed
feat: move tool search to API client
1 parent 17b22a8 commit c713e50

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/routes/tools/+page.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
1+
import { throwOnError, useAPIClient } from "$lib/APIClient";
42

53
export const load = async ({ url, fetch }) => {
6-
const r = await fetch(`${base}/api/v2/tools/search?${url.searchParams.toString()}`);
4+
const client = useAPIClient({ fetch });
75

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;
6+
return client.tools.search
7+
.get({ query: Object.fromEntries(url.searchParams.entries()) })
8+
.then(throwOnError);
159
};

0 commit comments

Comments
 (0)