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: extend description of handler
param for useAsyncData composable
#23389
docs: extend description of handler
param for useAsyncData composable
#23389
Conversation
Run & review this pull request in StackBlitz Codeflow. |
β Live Preview ready!
|
Interesting, thanks for the feedback, why using |
First of all, it is not my personal feedback it is one of the questions that people asked at least twice this week in our community.
That is correct if fetchUser returns data, but not all developers understand that it must return something. |
I think that example in the pinia docs is a bit misleading. I will have to think about a different example that makes sense and use that instead. Maybe, not use |
Co-authored-by: Daniel Roe <daniel@roe.dev>
It's quite tricky to understand, how the fetching data from store is supposed to work.
Probably because you may want to refresh data and check loading state, for example. So yes, not a surprise if people prefer fetching from store, having side effects and still utilize Also when you're rushing to migrate your app from Nuxt 2 to Nuxt 3, you may want to copy approaches used previously (though I can't say how many people need it, but probably documentation on both Nuxt and Pinia require more clarifications about data fetching from store. If fetching data from store the way I described above isn't recommended, it could be explicitly explained. |
@vushe Nuxt 2 was based on vuex which is always global, so any state set on the server side with vuex was transited to client. So it was ok to fill a store there. I guess store usage should look like this:
But I agree this way causes some questions: In the same time, people who just start with Nuxt very often do something like this:
I know that documentation recommends using |
Thanks @MaxKostenko! What you wrote is very close to how I understood this, including thoughts about When we fetch from In addition, if we elaborate your first example more with So this is what I mean when writing, it's a challenge to understand, how fetching is supposed to work from store. Not mentioning problems that e.g. i18n brings when it can't suddenly detect a context from Yes, if it's a demo, you don't care from where you load data or where you store them. However, a developer of a solid application would be definitely happy to have a clear example instead of guessing. |
π Linked issue
resolves #23388
β Type of change
π Description
Some developers use useAsyncData composable for fulfilling
pinia
store. As a result, the handler returns nothing (undefined
) that leads to API request duplication on the client side. I extended the handler param's description to emphasize this feature.π Checklist