Added logout feature
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user