Nuxt.js: beforeRouteUpdate is called after asyncData

Created on 5 May 2020  路  16Comments  路  Source: nuxt/nuxt.js

Version

v2.12.2

Reproduction link

https://github.com/moltar/route-hooks#readme

Steps to reproduce

git clone [email protected]:moltar/route-hooks.git
cd route-hooks
npm i
npm run dev
open http://localhost:3000/foo/1
  1. Open browser console
  2. Click Next Page
  3. Observe console.log output

What is expected ?

beforeRouteUpdate should be called before asyncData

What is actually happening?

beforeRouteUpdate is called after asyncData

This bug report is available on Nuxt community (#c10613)
bug-report

All 16 comments

Should it though? Within asyncData you can still decide to redirect to another page, so it makes sense that it runs before the nav guards for the initially intended route are triggered.

To me asyncData is associated with loading of a new page. By that logic any un-loading should happen before that.

I think all other guards come after, but I am just talking about beforeRouteUpdate.

Here's the full router nav flow for reference: https://router.vuejs.org/guide/advanced/navigation-guards.html#the-full-navigation-resolution-flow

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

It鈥檚 not stale. Still relevant.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

This bot is extremely annoying. The issue is not stale.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

The issue is not stale.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

The issue is not stale.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

Stale not

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

...

Hi @moltar

Actually, you should use the middleware that are called before asyncData instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

vadimsg picture vadimsg  路  3Comments

uptownhr picture uptownhr  路  3Comments

lazycrazy picture lazycrazy  路  3Comments