From f6d119c8528b6ed47374fc6a0b1aff1db4451d2e Mon Sep 17 00:00:00 2001 From: gourav Date: Sun, 14 Jul 2024 17:41:04 +0530 Subject: [PATCH] Added delete functionality --- frontend/src/components/CreateSecret.vue | 30 +++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/CreateSecret.vue b/frontend/src/components/CreateSecret.vue index 1b5ea89..7409826 100644 --- a/frontend/src/components/CreateSecret.vue +++ b/frontend/src/components/CreateSecret.vue @@ -42,6 +42,15 @@ type="primary" >Save & Close + Delete @@ -87,7 +96,7 @@ export default { }, body: JSON.stringify(bodyData), }; - console.log(requestOptions); + // console.log(requestOptions); await fetch(url, requestOptions) .then((response) => response.json()) .then((data) => console.log(data)); @@ -100,6 +109,25 @@ export default { (this.form.secret = ""); this.$emit("close", true); }, + + async deleteSecret() { + const url = `${this.apiBaseUrl}/secret`; + const token = sessionStorage.getItem("token"); + const bodyData = { data: btoa(JSON.stringify(this.form)) }; + bodyData["id"] = this.id; + const requestOptions = { + method: "DELETE", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + body: JSON.stringify(bodyData), + }; + // console.log(requestOptions); + await fetch(url, requestOptions) + .then((response) => response.json()) + .then((data) => console.log(data)); + }, }, created() {