Update API response message in Page component

IT WORKS
This commit is contained in:
Nils 2024-01-16 13:54:46 +01:00
parent 66fb96acba
commit 11051d85e6
2 changed files with 27 additions and 26 deletions

View File

@ -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<any>({ 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<any>({ 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() {
}}
>
<Typography sx={{ fontSize: 50, fontWeight: "bold", color: "white" }}>
Welcome to the Admin panel
Welcome to the Admin panel bv g
</Typography>
<Box

View File

@ -8,5 +8,5 @@ export default function handler(
req: NextApiRequest,
res: NextApiResponse<ResponseData>
) {
res.status(200).send({ message: 'test' })
res.status(200).send({ message: 'Ingrid' })
}