-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* custom fetch per call * docs update * code example for fetches during SSR * updated example * cahngeset * Update .changeset/wise-poems-do.md Co-authored-by: Drew Powers <1369770+drwpow@users.noreply.github.com> --------- Co-authored-by: Drew Powers <1369770+drwpow@users.noreply.github.com>
- Loading branch information
1 parent
ea65d72
commit fd3e96f
Showing
9 changed files
with
54 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"openapi-fetch": patch | ||
--- | ||
|
||
Added the option to provide custom fetch function to individual API calls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/openapi-fetch/examples/sveltekit/src/hooks.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Handle } from "@sveltejs/kit"; | ||
|
||
export const handle: Handle = async ({ event, resolve }) => { | ||
return resolve(event, { | ||
filterSerializedResponseHeaders(name) { | ||
// SvelteKit doesn't serialize any headers on server-side fetches by default but openapi-fetch uses this header for empty responses. | ||
return name === "content-length"; | ||
}, | ||
}); | ||
}; |
7 changes: 0 additions & 7 deletions
7
packages/openapi-fetch/examples/sveltekit/src/lib/api/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
import createClient from "openapi-fetch"; | ||
import type { paths } from "./v1"; | ||
import type { PageServerLoadEvent } from "../../routes/page-data/$types"; | ||
|
||
const client = createClient<paths>({ baseUrl: "https://catfact.ninja/" }); | ||
export default client; | ||
|
||
export const createServerClient = (fetcher: PageServerLoadEvent["fetch"]) => | ||
createClient<paths>({ | ||
baseUrl: "https://catfact.ninja/", | ||
fetch: fetcher, | ||
}); |
8 changes: 3 additions & 5 deletions
8
...ekit/src/routes/page-data/+page.server.ts → ...s/sveltekit/src/routes/page-data/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters