From 26f0066f9b2daa904d4fe4cac80841cbe40360ca Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Fri, 13 Nov 2020 20:43:44 -0500 Subject: get data from api --- src/App.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/App.js') diff --git a/src/App.js b/src/App.js index ee4fbc4..0600437 100644 --- a/src/App.js +++ b/src/App.js @@ -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 ( +
+

RIT Covid Dashboard

+

An error occurred

+
+ ); + if (!data) + return ( +
+

RIT Covid Dashboard

+

Loading latest data...

+
+ ); + return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+

RIT Covid Dashboard

+

Data Loaded

); } -- cgit v1.2.3