From 3a5f8ed6d643796a948d937840961a25192f1140 Mon Sep 17 00:00:00 2001 From: Sergo Date: Sun, 30 Jul 2023 01:34:10 +0300 Subject: [PATCH] quick and dirty fix for delete --- public/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/index.js b/public/index.js index f75eef0..7e6c207 100644 --- a/public/index.js +++ b/public/index.js @@ -32,6 +32,19 @@ function renderAliases(aliases) { tdCreated.innerText = alias.created const tdActions = document.createElement('td') const aDelete = document.createElement('a') + + aDelete.addEventListener('click', async () => { + const res = await fetch(`/aliases/${alias.id}`, { + method: 'DELETE' + }) + + if (res.ok) { + const data = await res.json() + renderAliases(data) + return + } + }) + aDelete.classList.add('btn') aDelete.classList.add('btn-danger') aDelete.innerText = 'Delete'