Skip to content
Snippets Groups Projects
Commit 63335393 authored by Trirst's avatar Trirst
Browse files

Update request to delete image

parent 4235e9e9
Branches
No related tags found
No related merge requests found
......@@ -3,12 +3,15 @@
<div id="item-container" v-for="(hash, index) in hashArray" :key="index">
<ImageItem :hash="hash" @checked="appendToDeleteArray"></ImageItem>
</div>
<button v-show="deleteArray.length" @click="deleteImages(deleteArray)">Delete</button>
<button v-show="deleteArray.length" @click="deleteImages(deleteArray)">
Delete
</button>
</section>
</template>
<script>
import ImageItem from "@/components/ImageItem.vue";
import { mapState } from "vuex";
export default {
components: {
ImageItem,
......@@ -23,6 +26,9 @@ export default {
required: true,
},
},
computed: {
...mapState(["stateSecret"]),
},
methods: {
appendToDeleteArray(...args) {
const [checked, hash] = args;
......@@ -31,8 +37,12 @@ export default {
: this.deleteArray.splice(this.deleteArray.indexOf(hash), 1);
},
deleteImages(deleteArray) {
const options = {
method: "DELETE",
headers: { secret: this.stateSecret },
};
for (let i = 0; i < deleteArray.length; i++) {
fetch(`/api/image/${deleteArray[i]}`, { method: "DELETE" });
fetch(`/api/image/${deleteArray[i]}`, options);
}
this.deleteArray = [];
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment