LasTres/js-src/login.ts

16 lines
449 B
TypeScript

export function checkLogin (setError: (set: string | null) => void,
setIsLoggedIn: (set: boolean) => void): void {
fetch('/player/check_login', {
method: 'POST',
mode: 'same-origin',
cache: 'no-cache'
}).then(async (response) => {
const data = await response.json()
if (data.is_login === 1) {
setIsLoggedIn(true)
}
}).catch((error) => {
console.log(error)
})
}