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() { export default function Page() {
const [data, setData] = useState<any>({ mes: "" });
useEffect(() => {
async function getData() {
const [data, setData] = useState<any[]>([]); try {
useEffect(() => {
async function getData() {
const response = await fetch(URL); const response = await fetch(URL);
const data = await response.json(); const jsonData = await response.json();
setData(data); setData(jsonData);
} catch (error) {
console.error("Error fetching data:", error);
} }
getData(); }
}, [])
getData();
}, []);
const rows = [ const rows = [

View File

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