[Vuejs]-How to access global data using laravel8 function in vue

0👍

When you use Vue/Vuex, your data will be stored in your state so you only need to get the state from computed. If your API call 2 times, it means you use it 2 times in your code. Just recheck.

0👍

When using Vue with the state management tool Vuex, when you send json response from Laravel to Vue and invoke your mutation, data will be stored in state and you can retrieve it from there. Be sure to use a getter for fetching state.

See:
https://vuex.vuejs.org/guide/state.html#getting-vuex-state-into-vue-components

and:

https://vuex.vuejs.org/guide/getters.html#property-style-access

  1. Try to use the Vue devtool chrome extension. It is very useful for debugging errors in Vue: https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd?hl=en

  2. Make sure to call the getter only once; somewhere in your code you have called it twice, therefore it gets the user twice.

Leave a comment