Created
April 23, 2019 20:41
-
-
Save kenny-io/6cf08127623f406ee36db0f413406e78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//src/components/Cards.vue | |
<template> | |
<b-container> | |
<div v-if="meals.length"> | |
<b-row> | |
<div v-bind:key="data.index" v-for="data in meals"> | |
<b-col l="4"> | |
<b-card | |
v-bind:title="data.strCategory" | |
v-bind:img-src="data.strCategoryThumb" | |
img-alt="Image" | |
img-top | |
tag="article" | |
style="max-width: 20rem;" | |
class="mb-2"> | |
<b-card-text>{{ `${data.strCategoryDescription.slice(0,100)}...` }}</b-card-text> | |
<b-button href="#" variant="primary">View food</b-button> | |
</b-card> | |
</b-col> | |
</div> | |
</b-row> | |
</div> | |
<div v-else> | |
<h5>No meals available yet 😢</h5> | |
</div> | |
</b-container> | |
</template> | |
<script> | |
import axios from "axios"; | |
export default { | |
data() { | |
return { | |
meals: [] | |
}; | |
}, | |
mounted() { | |
axios | |
.get("https://www.themealdb.com/api/json/v1/1/categories.php") | |
.then(response => { | |
this.meals = response.data.categories; | |
}) | |
.catch(err => { | |
console.log(err); | |
}); | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment