In my custom module named ShopItemCategory, I have a Getter
getters: {
shopItemsCategories: state => state.ShopItemsCategories.data,
},
Inside the component, there is a computed function I defined
computed: {
shopItemsCategories() {
return this.$store.getters['ShopItemCategory/shopItemsCategories'].filter(c => c.shop_id == this.$route.params.id)
},
},
Although the filter works fine when I click save, it throws an error upon refreshing
Vue warn]: Error in render: "TypeError: Cannot read property 'filter' of undefined"
The mutation that is dispatched in mounted is as follows
mutations: {
SET_SHOP_ITEM_CATEGORIES(state, shopItemsCategories) {
state.ShopItemsCategories = shopItemsCategories;
},
}
And in the mounted() method of the component, I dispatch a command
mounted() {
this.$store.dispatch('ShopItemCategory/getShopItemsCategories');
},