diff options
author | Galen Guyer <galen@galenguyer.com> | 2020-11-13 20:43:44 -0500 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2020-11-13 20:43:44 -0500 |
commit | 26f0066f9b2daa904d4fe4cac80841cbe40360ca (patch) | |
tree | 691f0d4b62c73ab4f486bea8ee4bdc564b1343c4 /src/App.js | |
parent | 5d5c39b6d318a91dd5062d829cecf3dcdd25ccab (diff) |
get data from api
Diffstat (limited to 'src/App.js')
-rw-r--r-- | src/App.js | 31 |
1 files changed, 22 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> ); } |