File tree Expand file tree Collapse file tree 2 files changed +3
-12
lines changed
packages/openapi-fetch/examples/sveltekit/src Expand file tree Collapse file tree 2 files changed +3
-12
lines changed Original file line number Diff line number Diff line change 1
1
import createClient from "openapi-fetch" ;
2
2
import type { paths } from "./v1" ;
3
- import type { PageServerLoadEvent } from "../../routes/page-data/$types" ;
4
3
5
4
const client = createClient < paths > ( { baseUrl : "https://catfact.ninja/" } ) ;
6
5
export default client ;
7
-
8
- export const createServerClient = ( fetcher : PageServerLoadEvent [ "fetch" ] ) =>
9
- createClient < paths > ( {
10
- baseUrl : "https://catfact.ninja/" ,
11
- fetch : fetcher ,
12
- } ) ;
Original file line number Diff line number Diff line change 1
- import { createServerClient } from "$lib/api/index.js" ;
1
+ import client from "$lib/api/index.js" ;
2
2
3
3
// Note: this uses Svelte’s custom fetcher as an example, but Node’s
4
4
// native fetch works, too. See Svelte’s docs to learn the difference:
5
5
// @see https://kit.svelte.dev/docs/load#making-fetch-requests
6
6
export async function load ( { fetch } ) {
7
- const client = createServerClient ( fetch ) ;
8
7
const fact = await client . GET ( "/fact" , {
9
- params : {
10
- query : { max_length : 500 } ,
11
- } ,
8
+ params : { query : { max_length : 500 } } ,
9
+ fetch,
12
10
} ) ;
13
11
14
12
return {
You can’t perform that action at this time.
0 commit comments