In my project, I have the main root component called App.vue
and another component named FileUploaderParent.vue
. I am using a dispatch promise to store data in the Vuex store. The dispatch call is made under the mounted lifecycle hook.
However, when I try to access the stored user data in the mounted function of a different component, I encounter an error stating that the data is undefined.
I understand that one workaround could be to make the same dispatch call again in the mounted function of the other component, but this feels like a hack and leads to redundant code.
Below is the code snippet for App.vue
:
<template>
<v-app>
<!-- Rest of the code goes here -->
</v-app>
</template>
<script>
// App.vue component script goes here
</script>
<style scoped>
// Styling for App.vue goes here
</style>
And here is the code snippet for FileUploaderParent.vue
:
<template>
<v-layout class="text-xs-center ">
<!-- FileUploaderParent component template code goes here -->
</v-layout>
</template>
<script>
// FileUploaderParent component script goes here
</script>
<style>
// Styling for FileUploaderParent.vue goes here
</style>
This is how the store actions and mutations are defined in store.js
:
actions: {
// Store actions definition goes here
},
mutations: {
// Store mutations definition goes here
}
For troubleshooting purposes, refer to the error image at this link: [Error Screenshot](https://i.sstatic.net/a3PN5.png)
If you need to know how to access store data in FileUploaderParent.vue
within the mounted function, feel free to ask!