Rerun nuxt route middleware if store getter changes without reloading the page?

  javascript, middleware, nuxt.js, vue.js

Given following middleware, whats the best way to rerun the logic when ever store.getters.authenticated changes, and not only on the initial load.

middleware/auth.js

export default function ({ store, redirect }) {
  if (!store.getters.authenticated) {
    return redirect({ name: "login" })
  }
}

Source: Ask Javascript Questions

LEAVE A COMMENT