feat: store logged account

This commit is contained in:
2025-05-24 12:05:57 +02:00
parent 06e0e90677
commit eb42b61b2c
8 changed files with 177 additions and 36 deletions

20
web/src/api/index.ts Normal file
View File

@ -0,0 +1,20 @@
export const handleApiError = async (response: Response) => {
try {
const json = await response.json();
console.log({ json });
const text = json.error ?? "unexpected error happpened";
return new Error(text[0].toUpperCase() + text.slice(1));
} catch (err) {
try {
console.log(err);
const text = await response.text();
if (text.length > 0) {
return new Error(text[0].toUpperCase() + text.slice(1));
}
} catch (err) {
console.log(err);
}
}
return new Error("Unexpected error happened");
};