How to mapping the JSON Object with the variable? I am not sure that my coding is correct or not. I just begin study in Vuejs. Please see my coding I want to map jSON data to the 'country' variable.
var appZone = new Vue({
el: '#el',
data() {
return {
country: [],
shoppingItems: [
{name: 'apple', price: '10'},
{name: 'orange', price: '12'}
]
}
},
mounted() {
axios.get('/wp-json/tour-api/v1/search/11361')
.then(function (response) {
console.log(response);
this.country = response.json();
})
.catch(function (error) {
console.log(error);
});
}
})
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="el">
<ul>
<li v-for="item in country">
{{ item.country_id }} - {{ item.title }}
</li>
</ul>
</div>
Here is my JSON data
