diff options
-rw-r--r-- | src/App.js | 31 | ||||
-rw-r--r-- | src/index.js | 1 |
2 files changed, 23 insertions, 9 deletions
@@ -1,18 +1,31 @@ +import useSWR from "swr"; import logo from "./logo.svg"; import "./App.css"; +const url = "https://rcpoller.galenguyer.com/api/v0/history"; + function App() { + const { data: data, error: error } = useSWR(url); + + if (error) + return ( + <div className="App"> + <h1>RIT Covid Dashboard</h1> + <h2>An error occurred</h2> + </div> + ); + if (!data) + return ( + <div className="App"> + <h1>RIT Covid Dashboard</h1> + <h2>Loading latest data...</h2> + </div> + ); + return ( <div className="App"> - <header className="App-header"> - <img src={logo} className="App-logo" alt="logo" /> - <p> - Edit <code>src/App.js</code> and save to reload. - </p> - <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer"> - Learn React - </a> - </header> + <h1>RIT Covid Dashboard</h1> + <h2>Data Loaded</h2> </div> ); } diff --git a/src/index.js b/src/index.js index ea743ca..4c1dc74 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ import ReactDOM from "react-dom"; import { SWRConfig } from "swr"; import "./index.css"; import App from "./App"; +import reportWebVitals from "./reportWebVitals"; const fetcher = (...args) => fetch(...args).then((res) => res.json()); |