Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can access route.meta on nuxt.js

Tags:

nuxt.js

I try to access route.meta on nuxt.js custom route.

I have set up this custom route in nuxt.config.js

  router: {
        extendRoutes (routes, resolve) {
          routes.push({
            path: '*',
            component: resolve(__dirname, 'my-component.vue'),
            meta: { accessToken: 'mydata' }
          })
        }
      },

Then I try from inside this component to get this meta value Ideally I want to have access to it thought my asyncData function.

Any ideas?

like image 610
Makis papadopoulos Avatar asked Sep 17 '25 20:09

Makis papadopoulos


1 Answers

Sure you can access meta inside asyncData, take a look at the sample

export default {
  asyncData(ctx) {
    const { route } = ctx;
    console.log(route.meta);
  }
}
like image 200
Farnabaz Avatar answered Sep 21 '25 22:09

Farnabaz