refactor: move project to frontend directory

This commit is contained in:
wea_ondara
2023-10-08 11:20:02 +02:00
parent 2a9cfba4d8
commit 34b0135da7
79 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
export class ApiError extends Error {
readonly statusCode: number;
constructor(statusCode: number, message?: string) {
super(message);
this.statusCode = statusCode;
}
}
export function handleJsonResponse<T>(res: Promise<Response>): Promise<T> {
return res.then(async e => {
if (e.status === 200) {
return await e.json();
}
throw new ApiError(e.status, 'Api error ' + e.status + ': ' + await e.text());
});
}