I have the following method in my Vue Component
loadMaintenances (query = {}) {
this.getContractorMaintenances(this.urlWithPage, query).then((response) => {
this.lastPage = response.data.meta.last_page
})
}
I want to pass the parameters (this.urlWithPage, query)
to my Vuex action as follows:
actions:{
async getContractorMaintenances ({ commit }, url, query) {
console.log(url);
console.log(query);
let response = await axios.get(url)
commit('PUSH_CONTRACTOR_MAINTENANCES', response.data.data)
return response
},
}
The problem is that the first parameter url
is returning a value but the second one query
is returning undefined
.
My mutation is as follows:
mutations: {
PUSH_CONTRACTOR_MAINTENANCES (state, data) {
state.contractor_maintenances.push(...data)
},
}
How can I get a value from the second parameter?
async getContractorMaintenances ({commit} , { url, query }) { console.log(url); console.log(query);
both url and query are returned as undefined. – Selah