data(){
return {
posts: [],
}
},
methods: {
changeCurrency: function () { // removed unused variable "value" here
axios.get('http://data.fixer.io/api/latest?access_key=xxxxxx')
.then(response => {
this.currency = response.data.rates.value
})
},
}
Solution 1 :
Solution 2 :
The parameter value
is passed to the changeCurrency function but it is never used in the function itself. Your Linter complains about it due to no-unused-vars
rule.
data(){
return {
posts: [],
}
},
methods: {
changeCurrency: function () { // <-- removed `value` from here. Should pass the linter
axios.get('http://data.fixer.io/api/latest?access_key=xxxxxx')
.then(response => {
this.currency = response.data.rates.value
})
},
}
Problem :
I want to get in the api with function value and return USD instead of making a lot of functions without value I’m trying this code but compiler returns ‘value’ is defined but never used
any ideas?
data(){
return {
posts: [],
}
},
methods: {
changeCurrency: function (value) {
axios.get('http://data.fixer.io/api/latest?access_key=509c9d50c1e92a712be9c8f1f964cf67')
.then(response => {
this.currency = response.data.rates.value
})
},
}
<button @click="changeCurrency(USD)">
USD
</button>