[Vuejs]-Vuex/Laravel pass parameter to dynamic url

0👍

You can access the router dynamic parameters by doing: this.$route.params.id

Example to get a user information via axios:

<template></template>
<script>
    export default {
        async created() {
            const userInformation = await axios.get(`user/${this.$route.params.userId}`);
        }
    }
</script>

This is assuming you have a route defined with the following:

const routes = [
  { path: 'user/:id', name: 'user-view', component: ComponentA }
]

Leave a comment