I have a vue function that I'm calling on page creation called fetchReport
That works fine, and I also have 2 other functions that I'm calling on change of select elements, which work as well, but here's my problem:
Currently, if I call handleTypeSelect or handleLocationSelect, they both submit the correct value but they submit it as itemType in the fetchReport call every time. I"m assuming it's because they only send one parameter value and that's the first parameter.
How can I modify this so that handleTypeSelect sends the value as itemType and handleLocationSelect sends the value as locationID?
created() {
this.fetchReport();
},
methods: {
fetchReport(itemType = '3', locationID = '10', startDate = new Date().toISOString().substring(0,10), endDate = new Date().toISOString().substring(0,10)) {
axios.get('/report/assets/data', {params:{itemType: itemType, startDate: startDate, endDate: endDate, locationID: locationID}})
.then(response => {
// handle success
console.log(response.data)
this.rows = response.data
})
},
handleTypeSelect() {
this.fetchReport(itemTypes.value);
},
handleLocationSelect() {
this.fetchReport(itemLocations.value);
}
}