import React, { useState, useEffect } from "react"; const Events = (props) => { const [state, setState] = useState({ user: { username: "" }, events: [{ id: 1, text: "Green Earth" }], }); const [stocks, setStocks] = useState([]); const requestOptions = { method: "GET", headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, }; const callAPI = () => { fetch(`${process.env.REACT_APP_API_ENDPOINT}/events/`, requestOptions) .then((response) => response.json()) .then((data) => { if (data !== undefined) { setState(data); } }); }; useEffect(() => { callAPI(); }, []); return (

Events

Hello {state.user.username}!

{state.events.map((event) => { return (
{event.text}
); })}
); }; export default Events;