Skip to content

Commit e76e715

Browse files
committed
updated example
1 parent 0317ffd commit e76e715

File tree

2 files changed

+3
-12
lines changed
  • packages/openapi-fetch/examples/sveltekit/src

2 files changed

+3
-12
lines changed
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import createClient from "openapi-fetch";
22
import type { paths } from "./v1";
3-
import type { PageServerLoadEvent } from "../../routes/page-data/$types";
43

54
const client = createClient<paths>({ baseUrl: "https://catfact.ninja/" });
65
export default client;
7-
8-
export const createServerClient = (fetcher: PageServerLoadEvent["fetch"]) =>
9-
createClient<paths>({
10-
baseUrl: "https://catfact.ninja/",
11-
fetch: fetcher,
12-
});

packages/openapi-fetch/examples/sveltekit/src/routes/page-data/+page.server.ts renamed to packages/openapi-fetch/examples/sveltekit/src/routes/page-data/+page.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { createServerClient } from "$lib/api/index.js";
1+
import client from "$lib/api/index.js";
22

33
// Note: this uses Svelte’s custom fetcher as an example, but Node’s
44
// native fetch works, too. See Svelte’s docs to learn the difference:
55
// @see https://kit.svelte.dev/docs/load#making-fetch-requests
66
export async function load({ fetch }) {
7-
const client = createServerClient(fetch);
87
const fact = await client.GET("/fact", {
9-
params: {
10-
query: { max_length: 500 },
11-
},
8+
params: { query: { max_length: 500 } },
9+
fetch,
1210
});
1311

1412
return {

0 commit comments

Comments
 (0)