Skip to content

Client data fetching in beforeMount mixin double-fetches #210

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

Closed
phil294 opened this issue Nov 9, 2018 · 3 comments
Closed

Client data fetching in beforeMount mixin double-fetches #210

phil294 opened this issue Nov 9, 2018 · 3 comments

Comments

@phil294
Copy link

phil294 commented Nov 9, 2018

Option 2, Fetch data after the matched view is rendered, calls asyncData in beforeMount.

The pseudo-syntax is

if (asyncData)
  asyncData()

This does not check if asyncData was already called by the server! Thus, guided by the official docs, this leads to duplicate fetches. In the case of dynamic module registration, even to duplicate modules.

What is the suggested way around this? Could we please have some documentation here?

If this issue is unclear, I explain it in greater detail at vuejs/vue#9252, including a repro link. But it is more of a docs issue

@LinusBorg
Copy link
Member

This belongs into the Vue repository where the code for the server-render is maintained.

This repository here is only for the docs.

@LinusBorg
Copy link
Member

Reopened afer I realized this does belong here after all (related: #210)

@phil294
Copy link
Author

phil294 commented Jul 7, 2019

This was fixed nicely with #214 with the addition of serverPrefetch() and updated docs. Great.

Store code splitting with preserveState: true does not work for me (state is missing; shouldnt it be preserveState: false server-side anyway? nothing to preserve here, hence empty state), however that is a seperate issue, not to be handled here.

@phil294 phil294 closed this as completed Jul 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants