I have a Vue template that currently calls a method (axios call) upon page load, which works well. However, I would like to modify it so that whenever I select an option from the dropdown menu, it will re-call the axios method with the selected option. Specifically, I am looking for a way to pass the selected value of 1, 2, or 3 into the fetchItems method as data = {value}
and trigger the axios call based on that selection:
<div class="form-group col-lg-3">
<label>Choose Item Type</label>
<select class="form-control" v-model="itemTypes" id="itemTypes">
<option v-for="itemTypeOption in itemTypeOptions" v-bind:value="itemTypeOption.value">{{ itemTypeOption.name }}</option>
</select>
</div>
export default {
data() {
return {
itemTypes: [],
itemTypeOptions: [
{value: 1, name: "A"},
{value: 2, name: "B"},
{value: 3, name: "All"}
]
}
},
created() {
this.fetchItems();
},
methods: {
fetchItems() {
axios.get('/report/items/data')
.then(response => {
this.rows = response.data
})
}
}
}