From ddbc977c01f63f44caeb9759978395c8866c6e6d Mon Sep 17 00:00:00 2001 From: afazio1 Date: Mon, 22 Apr 2024 00:44:01 -0400 Subject: [PATCH] fix fetching on undefined session --- frontend/src/screens/MainSearch.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/screens/MainSearch.tsx b/frontend/src/screens/MainSearch.tsx index 98b98bd..52dab6c 100644 --- a/frontend/src/screens/MainSearch.tsx +++ b/frontend/src/screens/MainSearch.tsx @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'; import '../styles/MainScreenWrapper.css'; import { getAuthHeaders } from '../utils/getAuthHeaders'; import { Professor, Course, Topic, Semester } from "../types/types"; +import { getSessionCookie } from '../contexts/session'; interface Filters extends Record { professor: string; @@ -23,6 +24,9 @@ const MainSearch: React.FC = () => { const navigate = useNavigate(); useEffect(() => { + if (!getSessionCookie()) { + return; + } // Fetch professors fetchProfessors(); // Fetch courses