blob: b0b04ba8a2833ab66d5b0d4b96d67b1495ffc332 (
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.status = '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.loginOptions = (response._data as any).data.options;
loginOptionsStore.status = 'idle'
}
},
});
}
|