diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 72907fa..6e71882 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -36,21 +36,24 @@ const columns: GridColDef[] = [ ]; -const URL= "http://100.101.64.38:3000/api/hello"; +const URL = "http://100.101.64.38:3000/api/hello"; export default function Page() { + const [data, setData] = useState({ mes: "" }); - - - const [data, setData] = useState([]); - useEffect(() => { - async function getData() { + useEffect(() => { + async function getData() { + try { const response = await fetch(URL); - const data = await response.json(); - setData(data); + const jsonData = await response.json(); + setData(jsonData); + } catch (error) { + console.error("Error fetching data:", error); } - getData(); - }, []) + } + + getData(); + }, []); const rows = [ diff --git a/src/pages/api/hello.ts b/src/pages/api/hello.ts index aef2a60..bf4edb1 100644 --- a/src/pages/api/hello.ts +++ b/src/pages/api/hello.ts @@ -8,5 +8,5 @@ export default function handler( req: NextApiRequest, res: NextApiResponse ) { - res.status(200).send({ Vorname: 'test' }) + res.status(200).send({ message: 'test' }) }