I am facing an issue where the mapGetters value is showing null in my computed property because the preferences method is not executed completely. I need to wait until the store has set the getter and setter. I have tried using async/await but it's not working as expected.
mounted() {
this.preferences();
this.selectedColumnsHeader;
},
methods: {
async preferences() {
await this.$store.dispatch('fetchPreferences');
}
}
store
fetchPreferences({ commit }) {
return http
.get('/help_ticket_preferences.json')
.then((res) => {
commit('setPreferences', res.data.preference);
})
.catch((error) => {
commit('setErrorMessage', `Sorry, there was an error fetching help ticket preferences ${error.message}.`);
});
},