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

Suggestion for useFetch Documentation: Add cache Option #27080

Closed
nd2024 opened this issue May 7, 2024 · 1 comment · Fixed by #27225
Closed

Suggestion for useFetch Documentation: Add cache Option #27080

nd2024 opened this issue May 7, 2024 · 1 comment · Fixed by #27225

Comments

@nd2024
Copy link

nd2024 commented May 7, 2024

I recently encountered an issue while using useFetch where I needed to prevent caching in a request. Unfortunately, it took me several hours of research to discover that a cache option exists for useFetch since it wasn't explicitly mentioned in the documentation. As a beginner, this was quite challenging and led to some frustration.

I believe adding a cache option to the documentation would greatly benefit users like myself. Clear documentation plays a crucial role in making tools accessible, especially for those who are just starting. By explicitly mentioning the cache option and providing usage examples, beginners would be able to leverage this functionality more efficiently, saving time and effort.

Example:

const { data, error} = await useFetch<GeneralResponse>('/bookmark/add', {
        method: 'post',
        cache: false,
        headers: {
            'Content-Type': 'application/json',
            Authorization: `Bearer ${token.value}`
        },
        body: {
           id: id
        },
    });
@manniL
Copy link
Member

manniL commented May 12, 2024

Related lines of code so documentation is easier:

cache: typeof opts.cache === 'boolean' ? undefined : opts.cache,

Though I am wondering - is this actively doing something at the moment? 🤔
The setting is passed to ofetch but I can't find the cache property there.

It is passed to fetch itself I think, so refers to https://developer.mozilla.org/en-US/docs/Web/API/fetch#cache I guess? 🤔
Might be better suited/documented in ofetch in general?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants