wrap main requests in try catch

This commit is contained in:
Georges-Antoine Assi
2025-08-23 08:20:03 -04:00
parent 4fbd8a2da0
commit de2be6985c
2 changed files with 13 additions and 9 deletions

View File

@@ -15,7 +15,7 @@
</head>
<body>
<div id="app"></div>
<div id="app" />
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@@ -20,18 +20,22 @@ async function initializeData() {
try {
const { data: heartbeatData } = await api.get("/heartbeat");
heartbeat.set(heartbeatData);
} catch (heartbeatError) {
console.error("Error fetching heartbeat: ", heartbeatError);
}
try {
const { data: userData } = await userApi.fetchCurrentUser();
auth.setUser(userData);
} catch (userError) {
console.error("Error loading user: ", userError);
}
try {
const { data: userData } = await userApi.fetchCurrentUser();
auth.setUser(userData);
} catch (userError) {
console.error("Error loading user: ", userError);
}
try {
const { data: configData } = await api.get("/config");
configStore.set(configData);
} catch (error) {
console.error("Error during initialization: ", error);
} catch (configError) {
console.error("Error fetching config: ", configError);
}
}