blakeblackshear.frigate/web/src/Debug.jsx

17 lines
480 B
React
Raw Normal View History

2021-01-09 18:26:46 +01:00
import { h } from 'preact';
import { ApiHost } from './context';
import { useContext, useEffect, useState } from 'preact/hooks';
export default function Debug() {
const apiHost = useContext(ApiHost);
const [config, setConfig] = useState({});
useEffect(async () => {
const response = await fetch(`${apiHost}/api/stats`);
const data = response.ok ? await response.json() : {};
setConfig(data);
}, []);
return <pre>{JSON.stringify(config, null, 2)}</pre>;
}