Added logout feature

This commit is contained in:
2023-10-30 13:43:52 -04:00
parent 16dac8941b
commit 1dd0b7caaa
2 changed files with 27 additions and 4 deletions

View File

@@ -26,6 +26,20 @@ async function click(ev) {
count.value = await get_clicks()
}
async function signout(ev) {
ev.preventDefault()
const api_url = '/api/auth'
const fetch_options = {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
}
let resp = await fetch(api_url, fetch_options)
console.log(resp)
window.location.reload()
}
</script>
@@ -33,6 +47,7 @@ async function click(ev) {
<main class="form-signin w-100 m-auto">
<p class="mt-5 mb-3 text-body">You have accessed this content {{ count }} times this session.</p>
<button type="submit" @click="click" class="btn btn-primary w-100 py-2">Refresh Content</button>
<button type="submit" @click="signout" class="btn btn-primary w-100 py-2">Sign out</button>
</main>
</template>