From b828e4850a5567d9b237780790e88fb688a6bb7f Mon Sep 17 00:00:00 2001 From: Shubhojeet Bera Date: Sun, 23 Jun 2024 20:55:51 +0530 Subject: [PATCH] fix: minor typo bug --- frontend/src/Components/Navbar2.jsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/Components/Navbar2.jsx b/frontend/src/Components/Navbar2.jsx index cb221ba..cb23f1c 100644 --- a/frontend/src/Components/Navbar2.jsx +++ b/frontend/src/Components/Navbar2.jsx @@ -18,7 +18,7 @@ import { BiSearch } from "react-icons/bi"; import { useSelector } from "react-redux"; function Navbar2() { - const backendURL = "https://youtube-clone-mern-backend.vercel.app" + const backendURL = "https://youtube-clone-mern-backend.vercel.app"; // const backendURL = "http://localhost:3000"; const [profilePic, setProfilePic] = useState(); const [userVideos, setUserVideos] = useState([]); @@ -90,15 +90,19 @@ function Navbar2() { useEffect(() => { const getData = async () => { try { - const response = await fetch(`${backendURL}/getchannel/${user?.email}`); - const { userProfile } = await response.json(); - setProfilePic(userProfile); + if (user?.email) { + const response = await fetch( + `${backendURL}/getchannel/${user?.email}` + ); + const { userProfile } = await response.json(); + setProfilePic(userProfile); + } } catch (error) { // console.log(error.message); } }; - return () => getData(); + getData(); }, [user?.email]); useEffect(() => {