diff --git a/frontend/app/explore/page.tsx b/frontend/app/explore/page.tsx index d27da6ac0..e98c821c9 100644 --- a/frontend/app/explore/page.tsx +++ b/frontend/app/explore/page.tsx @@ -18,31 +18,30 @@ export default function ExplorePage() { redirect("/login"); } - const fetchDocuments = async () => { - setIsPending(true); - try { - console.log( - `Fetching documents from ${process.env.NEXT_PUBLIC_BACKEND_URL}/explore` - ); - const response = await axios.get<{ documents: Document[] }>( - `${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`, - { - headers: { - Authorization: `Bearer ${session.access_token}`, - }, - } - ); - setDocuments(response.data.documents); - } catch (error) { - console.error("Error fetching documents", error); - setDocuments([]); - } - setIsPending(false); - }; - useEffect(() => { + const fetchDocuments = async () => { + setIsPending(true); + try { + console.log( + `Fetching documents from ${process.env.NEXT_PUBLIC_BACKEND_URL}/explore` + ); + const response = await axios.get<{ documents: Document[] }>( + `${process.env.NEXT_PUBLIC_BACKEND_URL}/explore`, + { + headers: { + Authorization: `Bearer ${session.access_token}`, + }, + } + ); + setDocuments(response.data.documents); + } catch (error) { + console.error("Error fetching documents", error); + setDocuments([]); + } + setIsPending(false); + }; fetchDocuments(); - }, [fetchDocuments]); + }, []); return (