Debug.jsx 480 B

12345678910111213141516
  1. import { h } from 'preact';
  2. import { ApiHost } from './context';
  3. import { useContext, useEffect, useState } from 'preact/hooks';
  4. export default function Debug() {
  5. const apiHost = useContext(ApiHost);
  6. const [config, setConfig] = useState({});
  7. useEffect(async () => {
  8. const response = await fetch(`${apiHost}/api/stats`);
  9. const data = response.ok ? await response.json() : {};
  10. setConfig(data);
  11. }, []);
  12. return <pre>{JSON.stringify(config, null, 2)}</pre>;
  13. }