when i try to push after login action i am getting unexpected error

240 Views Asked by At

i am using vuejs with vuex after login action i am trying to push to dashboard page but some how its throw this error

Uncaught (in promise) Error: Redirected when going from "/signin?redirect=%2F" to "/" via a navigation guard.

following is my router file to push to dashboard

const routes = [
  {
    path: "/signin",
    name: "signin",
    component: () => import("../components/Authentication/Signin.vue"),
  },

  {
    path: "/",
    name: "dashboard",
    component: () => import("../components/Dashboard/Dashboard.vue"),
    meta: {
      requiresAuth: true,
    },
  },
];
router.beforeEach((to, from, next) => {
  if (to.name == "dashboard" && to.meta.requiresAuth && token == null) {
    console.log(token);
    next({
      path: "/signin",
      query: {
        redirect: to.fullPath,
      },
    });
  } else if (to.name == "signin" && token != null) {
    console.log("signin");
    next("/");
  } else {
    console.log("else");
    next();
  }
});
0

There are 0 best solutions below