feat: implement unauthorized error handling and login popup
Deploy Miniplan / build (push) Failing after 42s
Deploy Miniplan / build (push) Failing after 42s
This commit is contained in:
@@ -30,11 +30,21 @@ function getToken(): string | null {
|
||||
return ""
|
||||
}
|
||||
|
||||
export class UnauthorizedError extends Error {
|
||||
constructor() {
|
||||
super("UnauthorizedError");
|
||||
}
|
||||
}
|
||||
|
||||
export namespace API {
|
||||
|
||||
export async function getPlan(id: number) {
|
||||
return api(`/plan?id=${id}`).then(res => res.json())
|
||||
.then(data => {
|
||||
return api(`/plan?id=${id}`).then(res => {
|
||||
if(res.status == 401) {
|
||||
throw new UnauthorizedError()
|
||||
}
|
||||
return res.json()
|
||||
}).then(data => {
|
||||
return {
|
||||
gottesdienste: data.gottesdienste,
|
||||
ministranten: data.ministranten,
|
||||
|
||||
Reference in New Issue
Block a user