Adds simple delete api
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
<h1>Cook Assistant</h1>
|
||||
<!-- Details View -->
|
||||
<section v-if="active_view > -1">
|
||||
<button @click="setActiveView(-1)">X close</button>
|
||||
<button @click="closeActiveView">X close</button>
|
||||
<h4>{{ items[active_view].title }}</h4>
|
||||
<h6>{{ categories[items[active_view].category].name }}</h6>
|
||||
<p><strong>{{ items[active_view].ingredients }}</strong></p>
|
||||
<button @click="deleteRecipe(active_view + 1)">DELETE !</button>
|
||||
</section>
|
||||
<!-- Category List View -->
|
||||
<section v-else>
|
||||
@@ -57,6 +58,16 @@
|
||||
setActiveView: function(id) {
|
||||
this.active_view = id - 1;
|
||||
},
|
||||
closeActiveView: function() {
|
||||
this.active_view = -1;
|
||||
},
|
||||
deleteRecipe: function(id) {
|
||||
fetch("/api/delete/" + id)
|
||||
.then((res) => res.json())
|
||||
.then((data) => console.log("Deleted :" + data))
|
||||
.catch((err) => console.error(err));
|
||||
this.closeActiveView();
|
||||
},
|
||||
fetchRecipesList: function() {
|
||||
fetch("/api/list")
|
||||
.then((res) => res.json())
|
||||
|
||||
Reference in New Issue
Block a user