14 lines
355 B
TypeScript
14 lines
355 B
TypeScript
export function isLoggedIn(): Promise<boolean> {
|
|
return fetch('http://localhost:31337/user/authorized', {
|
|
credentials: 'include',
|
|
})
|
|
.then((res) => {
|
|
return res.json().then((res_json) => {
|
|
const is_authorized = res_json.message
|
|
return Boolean(is_authorized)
|
|
})
|
|
})
|
|
.catch(() => {
|
|
return false
|
|
})
|
|
}
|