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

docs: update $fetch documentation #19356

Merged
merged 3 commits into from Mar 9, 2023
Merged

docs: update $fetch documentation #19356

merged 3 commits into from Mar 9, 2023

Conversation

ozum
Copy link
Contributor

@ozum ozum commented Mar 1, 2023

It is confusing why data is fetched twice when using $fetch on the client side without wrapping it with useAsyncData. It is explained here clearly. This PR updates docs to add clarification.

πŸ”— Linked issue

#18731

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

It is confusing why $fetch fetches data twice when used on the client side with SSR. This PR adds details about this behaviour.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

It is confusing why data is fetched twice when using `$fetch` on the client side without wrapping it with `useAsyncData`. It is explained [here](nuxt#18731 (comment)) clearly. This PR updates docs to add clarification.
@codesandbox
Copy link

codesandbox bot commented Mar 1, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@devzom
Copy link
Contributor

devzom commented Mar 1, 2023

Great one, bump, thanks! :)

docs/3.api/3.utils/$fetch.md Outdated Show resolved Hide resolved
docs/3.api/3.utils/$fetch.md Outdated Show resolved Hide resolved
@Atinux Atinux merged commit c8a5a4a into nuxt:main Mar 9, 2023
@pi0
Copy link
Member

pi0 commented Mar 10, 2023

We probably need to recommand and document context aware event.$fetch / useEventFetch() over directly $fetch inside the docs as this current version lacks the ability to automatically send headers (feature comparable to http/axios alternatives)

Copy link
Member

Atinux commented Mar 10, 2023

I don't see any reference of useEventFetch(), is this something you are imagining @pi0 ?

Also, event.$fetch is for server routes right?

@danielroe danielroe mentioned this pull request Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants