-
-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Custom fetch per call #1373
Conversation
🦋 Changeset detectedLatest commit: 1f23659 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@drwpow since this change was directly inspired by SvelteKit I would like to add some additional info to docs about making openapi-fetch work with SvelteKit. The issue is not directly related to a custom fetch so perhaps you would prefer a separate PR? Since your library reads content-length header when parsing a response, if you fetch during SSR SvelteKit will error because it doesn't serialize headers by default. The fix is this // hooks.server.ts
import type { Handle } from '@sveltejs/kit';
export const handle: Handle = async ({ event, resolve }) => {
return resolve(event, {
filterSerializedResponseHeaders(name) {
return name === 'content-length';
}
});
}; Can I add this example to docs in this same PR? |
Docs improvements are always appreciated! Maybe rather than having that snippet live just in docs, though, putting it in the |
But re: not serializing headers in SSR, that’s interesting! I’d be open to revisiting that default behavior after understanding why SvelteKit does that better (couldn’t find the “why” in a quick search, just other libraries requiring similar workarounds) |
@drwpow I've updated the examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you!
Before releasing this version, though, I want to do a little testing first to make sure the updated types generated from openapi-typescript@7 didn’t introduce any accidental breaking changes from openapi-fetch (it shouldn’t have, but I need to double-check).
One last thing—could you add a |
Co-authored-by: Drew Powers <[email protected]>
Thank you again! |
Changes
Closes #1369
How to Review
Adds the option to pass in custom fetch as fetchOption on per API call basis. Added a simple test to see that custom fetch overrides the one specified during client initialization.
Checklist
docs/
updated (if necessary)