Home

Issue: 1110

Let fetch know from which route do we navigate from

[issue link]

I have a page structure of:

pages/
  users/
    _userid.vue
  users.vue

with meta-component inside users.vue. So basically I have a list of items, which is always shown when navigated at /users/*, and a pane for item details, which is shown when navigated at /users/1 etc. In the list page I use fetch method to fetch the user_list from my API. Then I render items as a list of <nuxt-link :to="'/users/' + user.id" v-for="user in user_list">. So far it works okay. I just need to mention that the list has some own state, like filtering.

Then, when I want to get back from the particular item details to the list, thus from /users/1 to /users I don’t want to lose the state of my list. Which, unfortunately, happens, as the fetch method of users.vue is being called again.

So I thought: maybe there should be a way to figure out from which route do we navigate from, so I can disable fetching when returning from details view to the list-only view?

Is there a way for nuxt to play nicely with https://router.vuejs.org/en/advanced/navigation-guards.html?

This feature request is available on Nuxt.js community (#c972)