diff --git a/frontend/src/components/RecipeModel.vue b/frontend/src/components/RecipeModel.vue
index c6db830..7374cbc 100644
--- a/frontend/src/components/RecipeModel.vue
+++ b/frontend/src/components/RecipeModel.vue
@@ -35,9 +35,7 @@
-
-
{
- this.$log.debug("Data loaded: ", response.data)
- this.recipes = response.data
- })
- .catch(error => {
- this.$log.debug(error)
- this.error = "Failed to load recipes"
- })
- .finally(() => this.loading = false)
+ this.populateRecipes()
},
+ methods: {
+ populateFromFridge() {
+ api.getRecipesForFridge()
+ .then(response => {
+ this.$log.debug("Data loaded: ", response.data)
+ this.recipes = response.data
+ })
+ .catch(error => {
+ this.$log.debug(error)
+ this.error = "Failed to load recipes"
+ })
+ .finally(() => this.loading = false)
+ },
+
+ populateRandom() {
+ api.getRandom()
+ .then(response => {
+ this.$log.debug("Data loaded: ", response.data)
+ this.recipes = response.data
+ })
+ .catch(error => {
+ this.$log.debug(error)
+ this.error = "Failed to load recipes"
+ })
+ .finally(() => this.loading = false)
+ },
+
+ populateRecipes() {
+ api.getAll()
+ .then(response => {
+ this.$log.debug("Data loaded: ", response.data)
+ this.items = response.data
+ })
+ .catch(error => {
+ this.$log.debug(error)
+ this.error = "Failed to load items"
+ })
+ .finally(() => {
+ if (this.items.length > 3) {
+ this.populateFromFridge()
+ } else {
+ this.populateRandom()
+ }
+ })
+ }
+ }
}
export default Recipes
-
-
-
-
-