function App() {
const [ startupData, setStartupData ] = React.useState([]);
React.useEffect(() => {
fetch('http://localhost:8080/api/v1/startup')
.then(res => res.json())
.then(data => setStartupData(data))
.catch(err => console.error('Err: ', err));
}, []);
if (startupData?.length === 0) {
return <h1>Loading...</h1>;
}
return (
<div>
<table border="2">
<thead>
<tr>
<td>startup_id</td>
<td>startup_name</td>
<td>startup_descr</td>
<td>startup_price</td>
</tr>
</thead>
<tbody>
{startupData?.map(startup => (
<tr key={startup.startup_id}>
<td>{startup.startup_id}</td>
<td>{startup.startup_name}</td>
<td>{startup.startup_descr}</td>
<td>{startup.startup_price}</td>
</tr>
))}
</tbody>
</table>
</div>
)
}