owltide/components/LogOutButton.vue

20 lines
396 B
Vue
Raw Normal View History

<template>
<button type="button" @click="logOut">Log out</button>
</template>
<script setup lang="ts">
const { refresh: sessionRefresh } = useAccountSession();
async function logOut() {
try {
await $fetch.raw("/api/auth/session", {
method: "DELETE",
});
await sessionRefresh();
} catch (err: any) {
alert(`Log out failed: ${err.statusCode} ${err.statusMessage}`);
}
}
</script>