'use client' import { Guest } from '@/app/lib/definitions'; import { useState, Suspense } from 'react'; export default function guestsTable() { const url = "http://localhost:3001/guests.json"; const getData = (): Guest[] => { var guests: Guest[] = []; fetch(url) .then((response) => response.json()) .then((data) => { data.data.map((record: any) => { guests.push({ id: record.id, name: record.attributes.name, email: record.attributes.email, }); }); }); return guests; } const [guests, setGuests] = useState(getData()); return (
{guests.map((guest) => ( ))}
Name Email Status
{guest.name} {guest.email} Confirmed
); }