We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 295a01d + f4ed3eb commit 9246cffCopy full SHA for 9246cff
1 file changed
src/App.tsx
@@ -37,9 +37,18 @@ const ProtectedRoute = ({ children }: { children: JSX.Element }) => {
37
38
useEffect(() => {
39
const checkAuth = async () => {
40
- const currentUserId = getCurrentUserId();
41
- const response = await getUserInfoApi(currentUserId);
42
- setIsAuthenticated(response.isSuccess);
+ try {
+ const currentUserId = getCurrentUserId();
+ if (!currentUserId) {
43
+ setIsAuthenticated(false);
44
+ return;
45
+ }
46
+
47
+ const response = await getUserInfoApi(currentUserId);
48
+ setIsAuthenticated(response.isSuccess);
49
+ } catch (error) {
50
51
52
};
53
checkAuth();
54
}, []);
0 commit comments