import { useState } from 'react'; export default function DataFetcher() { const [data, setData] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const fetchData = async () => { setLoading(true); setError(null); try { const response = await fetch('/api/status'); if (!response.ok) { throw new Error('Network response was not ok'); } const result = await response.json(); setData(result); } catch (err) { setError(err.message); } finally { setLoading(false); } }; return (
Status: {data.status}
Message: {data.message}
Timestamp: {data.timestamp}
Uptime: {Math.floor(data.uptime)}s