DevonDahon
DevonDahon

Reputation: 8350

How to access $auth from Nuxt middleware?

How to access $auth from a middleware with Nuxt ?

export default function ({ store, redirect }) {
  console.log(store.state.foo)
}

Upvotes: 0

Views: 1330

Answers (2)

DevonDahon
DevonDahon

Reputation: 8350

This works but there might be a better answer.

export default function (context) {
  if (context.$auth.user.foo) {
    context.redirect('/bar')
  }
}

Upvotes: 0

kissu
kissu

Reputation: 46632

This one may work too I guess.

export default function ({ $auth })

Upvotes: 3

Related Questions