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'