I have a graph with a simple dropdown list with years and I need to pass the year whenever it's modified by the user so the graph will show that year's data.
For example, when I try to access the parameters from this method all i get is undefined:
fetchBarChartData({ anio, sort }) {
var self = this;
console.log(anio);
fetch("https://demo8358110.mockable.io/year/" + this.anio) // insert your api call here
.then(function(response) {
var r = response.json();
return r;
})
.then(function(data) {
self.values = data.values;
self.valuesline = data.valuesline;
self.loaded = true;
});
https://demo8358110.mockable.io/year/undefined
EDIT: I've added an example https://codesandbox.io/s/vue-template-x4z7b