I have this currency code api, https://openexchangerates.org/api/currencies.json
How to populate json into dropdownlist for VueJs?
This is my code at the moment:
new Vue({
el: "#app",
data() {
return {
currencyFrom: null,
loading: true,
errored: false
};
},
mounted() {
axios
.get("https://openexchangerates.org/api/currencies.json")
.then(response => (this.currencyFrom = response))
.catch(error => {
console.log(error);
this.errored = true;
})
.finally(() => (this.loading = false));
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
<div id="app">
<div v-if="loading">Loading...</div>
<select class="form-control" name="currency_from_code" id="currency_from_code" v-else>
<option v-for="currency in currencyFrom" >{{ currency }}</option>
</select>
</div>
It does manage to load the json but the dropdownlist is not working.