pomme/frontend/src/routes/logout/+page.svelte
Sam Therapy 5328d3f4ed fix build + fix lint
Signed-off-by: Sam Therapy <sam@samtherapy.net>
2023-02-03 23:44:51 +00:00

23 lines
382 B
Svelte

<script lang="ts">
import { goto } from '$app/navigation';
let promise = fetch(`/api/logout`, {
method: 'post'
}).then(async (response) => {
if (response.ok) {
goto('/');
} else {
const res = await response.json();
throw new Error(res.message);
}
});
</script>
{#await promise}
<p />
{:then}
<p />
{:catch error}
<p style="color: red">{error}</p>
{/await}