unjs / unjs/ofetch

stateful fetch client

Open
#435 4 comments 26 reactions 1 assignee View on GitHub

@pi0 is already working on this.

Since Aug 28, 2024.

discussion enhancement
Dominant language
TypeScript
Stars
5.4k
Forks
195
PR merge metrics
No merged PRs in 30d

Description

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:

  • Sharable headers
  • Cookie jar (#382)
  • Global interceptors such as auth

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.