blob: 707a04fb409b01a7f5a4fa7de57bc4a8dd28f992 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { useLoginOptionsStore } from "~/stores/login-options";
export default function() {
const loginOptionsStore = useLoginOptionsStore();
const errorStore = useErrorStore();
const config = useRuntimeConfig();
loginOptionsStore.setStatus('pending')
$fetch(config.public.baseURL + '/login', {
method: 'GET',
server: false,
lazy: true,
onResponse: ({ response }) => {
if (!response.ok) {
errorStore.setError(response._data.message || 'An unknown error occurred');
}
if (response._data) {
loginOptionsStore.setLoginOptions((response._data as any).data.options);
loginOptionsStore.setStatus('idle')
}
},
});
}
|