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

[spa] Fetch is not called when accessing child page directly #1423

Closed
cretueusebiu opened this issue Aug 19, 2017 · 7 comments
Closed

[spa] Fetch is not called when accessing child page directly #1423

cretueusebiu opened this issue Aug 19, 2017 · 7 comments

Comments

@cretueusebiu
Copy link

cretueusebiu commented Aug 19, 2017

The fetch method is not called when you access a child page directly.

Reproduction project: https://github.com/cretueusebiu/nuxt-fetch-issue

Start the project and open the console:

  • You should see fetch@index.vue.
  • Now click on the Child button and you'll see fetch@child.vue.
  • While on the /child page, refresh the page and only fetch@child.vue is shown.

Is this the expected behavior ?

From looking at the code this line seems to prevent fetch from being called on the parent component.

nuxt

This bug report is available on Nuxt.js community (#c1265)
@gtso86
Copy link

gtso86 commented Aug 20, 2017

@cretueusebiu What exactly are you expecting? When hard reload child page call fetch@index.vue too?

I'm starting to use Nuxt recently, but for me, this is the expected behavior since index (home) and child are 2 different pages, with 2 different codes.

I normally use a middleware to make things globally. EG something need to happen in every page, like verify if the user is authenticated...

@cretueusebiu
Copy link
Author

@gtso86 Yes.

@gtso86
Copy link

gtso86 commented Aug 20, 2017

@cretueusebiu got it...

When I disabled the mode: spa inside the nuxt.config.js and hard refresh the child page, I got both logs on my terminal, but still getting only the last one on devtools

image

@Atinux
Copy link
Member

Atinux commented Aug 21, 2017

Hi @cretueusebiu @gtso86

It seems to be a bug indeed, it should not call any fetch method on reload since everything is server-rendered.

I will take a look at it.

@Atinux Atinux self-assigned this Aug 21, 2017
@Atinux Atinux changed the title Fetch is not called when accessing child page directly [spa] Fetch is not called when accessing child page directly Aug 21, 2017
@Atinux
Copy link
Member

Atinux commented Aug 21, 2017

I just tried and universal mode is working perfecly:

  • / -> fetch@index.vue in server console
  • /child -> fetch@index.vueandfetch@child.vue` in server console
  • Navigating client-side from / to /child -> only fetch@child.vue in client console

But with spa mode (only client console):

  • / -> fetch@index.vue in console
  • /child -> only fetch@child.vue` in console == BUG

Woking on it :)

@Atinux Atinux closed this as completed in fed644d Aug 21, 2017
@Atinux Atinux reopened this Aug 21, 2017
@Atinux
Copy link
Member

Atinux commented Aug 21, 2017

It's fixed with fed644d

Will be available in rc6 :)

@lock
Copy link

lock bot commented Nov 3, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 3, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants