blob: 02ebe389a54129a97f0ef38d26b220b49aa93f04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { useContext } from 'react';
import { SettingsContext } from '../../utils/settings_context';
export const Home = () => {
const [, dispatch] = useContext(SettingsContext);
const logout = async () => {
const res = await fetch('/sessions', {
method: 'DELETE',
});
if (res.status === 200) {
dispatch({ type: 'update', payload: { jwt: undefined } });
}
};
return (
<div>
<h1>Welcome</h1>
<button type="button" onClick={logout}>
Logout
</button>
</div>
);
};
|