Skip to content
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

stateful fetch client #435

Open
pi0 opened this issue Aug 28, 2024 · 3 comments
Open

stateful fetch client #435

pi0 opened this issue Aug 28, 2024 · 3 comments
Assignees
Labels
discussion enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Aug 28, 2024

Describe the feature

ofetch/$fetch same as native fetch is stateless by-design. This has safety advantages when ofetch is deeply integrated into tools such as Nitro and Nuxt and prevents global side effects and potential header leaks.

However, there are also good use cases of having stateful fetch instances:

I think $fetch.withState() could be useful.

@pi0 pi0 added enhancement New feature or request discussion labels Aug 28, 2024
@pi0 pi0 mentioned this issue Aug 28, 2024
1 task
@pi0 pi0 self-assigned this Aug 28, 2024
@YoungKamilson
Copy link

It's very good idea especially useful for testing API's

@guyaumetremblay
Copy link

Hi @pi0
What's the difference between this and ofetch.create ?

@pi0
Copy link
Member Author

pi0 commented Sep 26, 2024

@guyaumetremblay ofetch.create creates instance with immutable defaults. this version has mutable state (and most importantly working cookies, just like a browser tab)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants