From 11b06695525d3c702e7fc81b63fbee24302d69aa Mon Sep 17 00:00:00 2001 From: Kristoffer Longva Eriksen Date: Wed, 23 Mar 2022 10:09:34 +0100 Subject: [PATCH] trying to fetch API --- src/client/src/frontpage.js | 56 ++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/client/src/frontpage.js b/src/client/src/frontpage.js index c422242..18a0572 100644 --- a/src/client/src/frontpage.js +++ b/src/client/src/frontpage.js @@ -15,12 +15,12 @@ import CssBaseline from "@mui/material/CssBaseline"; import AppBar from "@mui/material/AppBar"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; -import Grid from '@mui/material/Grid' -import Box from '@mui/material/Box' +import Grid from "@mui/material/Grid"; +import Box from "@mui/material/Box"; function CreateButton(props) { return ( - + @@ -30,7 +30,7 @@ function CreateButton(props) { function OverviewButton(props) { return ( - + @@ -58,29 +58,53 @@ function ListElement(props) { ); } +function TournamentList() { + let [data, setData] = React.useState(null); + React.useEffect(() => { + fetch("https://jsonplaceholder.typicode.com/todos/1") + .then((res) => res.json()) + .then((data) => { + console.log(data); + }) + .catch((err) => console.log("oopsie")); + }, []); + return
{data && data.map((id) => console.log(id))}
; +} + function Home() { return ( - + This is an Appbar
- - - - - - - - + + + + + + + + +
-
- -
+
); }