Is it possible to pass the current logged in user's id to the params
of a router link?
This is my current code and I want to render information in a page based on the params id
routes.js
{
path: '/objective/employee/:id',
name: 'employee-objective',
component: () => import('@/views/EmployeeObjective'),
meta: { requiresAuth: true }
},
Component.vue
created () {
this.$store.dispatch('authUserInformation')
},
computed: {
loggedIn () {
return this.$store.getters.loggedIn
},
authUser () {
return this.$store.state.authUser
}
}
router-link
<router-link :to="{ name: 'employee-objective',
params: {
id: // this.$store.state.authUser <- does not work
// authUser[0].id <- does not also work
}}">
Click Here
</router-link>
<router-link :to="{ name: 'employee-objective', params: { id: $store.state.authUser }}">
– Karma Blackshaw