<script>
    import { logOut} from '../apiServer';
    import { currentUser } from '../store';

    async function handleLogout(event) {
        event.preventDefault();
        const response = await logOut();
        if (200 <= response.status && response.status < 300) {
            currentUser.update(() => null);
        }
    }
</script>

<form on:submit={handleLogout}>
    <button type="submit">log out</button>
</form>

<style>
</style>
