Skip to content

Commit

Permalink
fix ilmomasiina crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jan 20, 2024
1 parent 809c88a commit 79d4900
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/web/src/lib/api/external/ilmomasiina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ const baseUrl = process.env.PUBLIC_ILMOMASIINA_URL!;
export const fetchEvents = async (): Promise<
ApiResponse<IlmomasiinaEvent[]>
> => {
const response = await fetch(`${baseUrl}/api/events`);
if (!response.ok) {
try {
const response = await fetch(`${baseUrl}/api/events`);
if (!response.ok) {
return err("ilmomasiina-fetch-fail");
}
const data = (await response.json()) as IlmomasiinaResponse;

return ok(data);
} catch (error) {
return err("ilmomasiina-fetch-fail");
}
const data = (await response.json()) as IlmomasiinaResponse;

return ok(data);
};

0 comments on commit 79d4900

Please sign in to comment.