From 11051d85e604e10342a4c1201b09ba96978ec077 Mon Sep 17 00:00:00 2001 From: Nils <1059147@bkrnet.de> Date: Tue, 16 Jan 2024 13:54:46 +0100 Subject: [PATCH] Update API response message in Page component IT WORKS --- src/app/dashboard/page.tsx | 51 +++++++++++++++++++------------------- src/pages/api/hello.ts | 2 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 6e71882..c73a157 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -7,10 +7,32 @@ import axios from "axios"; import { useEffect, useState } from "react"; -// ... +// ...3 -const columns: GridColDef[] = [ + + + +const URL = "http://100.101.64.38:3000/api/hello"; + +export default function Page() { + const [data, setData] = useState({ message: "" }); + + useEffect(() => { + async function getData() { + try { + const response = await fetch(URL); + const jsonData = await response.json(); + setData(jsonData); + } catch (error) { + console.error("Error fetching data:", error); + } + } + + getData(); + }, []); + + const columns: GridColDef[] = [ { field: 'Vorname', headerName: 'Vorname', @@ -35,29 +57,8 @@ const columns: GridColDef[] = [ }, ]; - -const URL = "http://100.101.64.38:3000/api/hello"; - -export default function Page() { - const [data, setData] = useState({ mes: "" }); - - useEffect(() => { - async function getData() { - try { - const response = await fetch(URL); - const jsonData = await response.json(); - setData(jsonData); - } catch (error) { - console.error("Error fetching data:", error); - } - } - - getData(); - }, []); - - const rows = [ - { id: "1", Vorname:{data}, Nachname: "test", Anstelldatum: "test", Geburtstag: "test" } + { id: "1", Vorname:data.message, Nachname: "test", Anstelldatum: "test", Geburtstag: "test" } ]; return ( @@ -72,7 +73,7 @@ export default function Page() { }} > - Welcome to the Admin panel + Welcome to the Admin panel bv g ) { - res.status(200).send({ message: 'test' }) + res.status(200).send({ message: 'Ingrid' }) }