Update response object in API handler

This commit is contained in:
Nils 2024-01-16 13:43:56 +01:00
parent 327bfb2760
commit 66fb96acba
2 changed files with 14 additions and 11 deletions

View File

@ -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<any>({ mes: "" });
const [data, setData] = useState<any[]>([]);
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 = [

View File

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