import useSWR from "swr"; import Link from "next/link"; import { useUser } from "../utils/auth/useUser"; import DefaultLayout from "../components/defaultLayout"; import styles from "./index.module.css"; import { Box, Button, Container, Typography } from "@material-ui/core"; const fetcher = (url, token) => fetch(url, { method: "GET", headers: new Headers({ "Content-Type": "application/json", token }), credentials: "same-origin", }).then((res) => res.json()); const Index = () => { const { user, logout } = useUser(); const { data, error } = useSWR( user ? ["/api/getFood", user.token] : null, fetcher ); return ( Start creating your leagues ); }; export default Index;