How can I call mixin function in middleware with NUXT.js?
I am trying to do this:
export default function(context) {
// init auth token from the local store or cookies
context.initAuth(context.req)
if (!context.store.getters['sessionStorage/isAuthenticated']) {
context.redirect("/login")
}
}
where initAuth()
function is located in the plugins/auth.js
mixin file
You can't call mixin in middleware, because mixin is something related to vue-component instanse. Did you mean you want to call a function? Then you doing it right, except you should inject your function into the context.