ive setup my Vuex store and modules with all endpoints declared in my actions and connected to the getters too.
but my app returns this error compilation.
Help me check what might be wrong.
I have this in my methods
...mapActions('codes', [
'fetchCode',
'fetchCodes',
'updateCode',
'selectCode',
'setSelectAllState'
]),
async fetchData({page, sort}) {
let data = {
name: this.filters.name ? this.filters.name : null,
from_date:
this.filters.from_date === ''
? this.filters.from_date
: this.filters.from_date,
to_date:
this.filters.to_date === ''
? this.filters.to_date
: this.filters.to_date,
orderByField: sort.fieldName || 'created_at',
orderBy: sort.order || 'desc',
page,
}
this.isRequestOngoing = true
let response = await this.fetchCodes(data)
this.isRequestOngoing = false
return {
data: response.data.result.data,
}
},
It only returns this error in my browser console
[Vue warn]: Error in mounted hook (Promise/async): "TypeError: Cannot read properties of undefined (reading 'page')"
I've googled the hell out of this error, checked my api numerous times.. :(
Meanwhile the
let response = await this.fetchCodes(data)
gets its data from this end (actions.js)
import * as types from './mutation-types'
export const fetchCodes = ({commit, dispatch, state}, params) => {
return new Promise((resolve, reject) => {
window.axios
.get(`/api/myendpoint`, {params})
.then((response)=>{
commit(types.FETCH_CODES, response.data.result.data)
resolve(response)
})
.catch((err)=>{
reject(err)
})
})
}
I've fixed the mutations to connect with their states too