Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit ca1271c

Browse files
author
Manuel Proß
committed
refactor(web): add routes enum for fetching data from specific route handlers
1 parent e2bb733 commit ca1271c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

web/src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import useSWR from "swr";
33
import Hero from "@/components/Strapi/Sections/HeroSection";
44
import PageContent from "@/components/Strapi/Sections/Content";
5-
import { PageAttributes } from "@/types/strapi";
5+
import { PageAttributes, Routes } from "@/types/strapi";
66

77
const fetcher = (url: string) => fetch(url).then(res => res.json() as Promise<PageAttributes>);
88

99
export default function Home() {
10-
const { data } = useSWR("/api/homepage", fetcher);
10+
const { data } = useSWR(`/api/${Routes.homepage}`, fetcher);
1111

1212
return (
1313
<main className="relative z-1 pb-12">

web/src/types/strapi.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ export type NewsPost = {
105105
id: number;
106106
attributes: NewsPostContent;
107107
};
108+
109+
export enum Routes {
110+
homepage = "homepage",
111+
}

0 commit comments

Comments
 (0)