Open bofeiw opened 1 year ago
Hi,
It looks like you are trying to access the getters property of the parkingPlaces store, but it is undefined. When you export the default object of the parkingPlaces.js store, you need to include the getters property.
You can add the getters property to the parkingPlaces.js store as follows:
export default {
state,
mutations: {
SET_PARKINGPLACES(state, parkingPlaces) {
state.all = parkingPlaces
}
},
actions: {
async ENSURE({commit}) {
commit('SET_PARKINGPLACES', [
{
"id": 1,
"name": "Chandler Larson",
"post": "37757",
"coordinates": {
"lng": -1.824377,
"lat": 52.488583
},
"total_spots": 0,
"free_spots": 0
},
]
)
}
},
getters: {
@shamsmosowi seems like the answer is cut off half way, what happened to the ai?
Can anyone help with the below, I am getting the following error Cannot read properties of undefined (reading 'getters')
I am working on a project where my stores should return an array to my index.vue
Is there also any way I can get around this without having to use the Vuex store?
My store directory contains the below files
index.js
export const state = () => ({}) parkingPlaces.js
import {getters} from '../plugins/base'
const state = () => ({ all: [] });
export default { state, mutations: { SET_PARKINGPLACES(state, parkingPlaces) { state.all = parkingPlaces } }, actions: { async ENSURE({commit}) {
getters: { ...getters } } index.vue
lat: {{ location.coordinates.lat }}, lng: {{ location.coordinates.lng }}
base.js
import getters from "./getters";
export {getters};
getters.js
export default { all: state => state.all }; Image of my file directory below enter image description here
image of error enter image description here