Spaces:
Sleeping
Sleeping
feat: move tool search to API client
Browse files- src/routes/tools/+page.ts +5 -11
src/routes/tools/+page.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
| 1 |
-
import {
|
| 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
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 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 |
};
|