19 lines
555 B
TypeScript
19 lines
555 B
TypeScript
import axios from "axios";
|
|
|
|
export class Login
|
|
{
|
|
email?: string;
|
|
password?: string;
|
|
|
|
static login(login: Login, onSuccess: (token: string) => void, onError: () => void)
|
|
{
|
|
axios.post<string>(useRuntimeConfig().public.baseUrl + '/sessions/' + useRuntimeConfig().public.realmId, login, { maxRedirects: 1 })
|
|
.then((response) => {
|
|
console.log(response.headers['Location']);
|
|
onSuccess(response.data);
|
|
})
|
|
.catch(() => {
|
|
onError();
|
|
});
|
|
}
|
|
} |