axios get return data from api vue code example

Example 1: vuejs list items from axios

<ul>
    <li v-for="food in foods">
        <h2>{{food.name}}</h2>
        <ul>
              <li v-for="nutrient in food.nutrients">{{nutrient.nutrient_id}}</li>
        </ul>
    </li>
</ul>


axios.get(url).then(response => { 
    this.foods = response.data.report.foods
})

Example 2: how to use api url in vue

<a :href="post.url" target="_blank"><img :src="post.image_url"></a>

Tags:

Misc Example