I'm just getting started with React. And I ran into such a problem: how in useEffect can I make it so that after the first request is executed, take the received data from it and send it to the second one (following it)? Thanks in advance.
const FullSizeWorkSchedule = () => {
const [events, setEvents] = useState([])
const [user, setUser] = useState([])
const [EventsListActive, setEventsListActive] = useState(true)
useEffect(() => {
const fetch2 = fetch('/profile')
.then(res => res.json())
.then(user => {setUser(user)});
// Send example user state
const fetch1 = fetch('/events')
.then(res => res.json())
.then(events => {setEvents(events)});
},[])