Skip to content

Commit

Permalink
Added A Nullish Check to authentication Ref #14
Browse files Browse the repository at this point in the history
  • Loading branch information
rhit-villencr committed Oct 20, 2024
1 parent 517d223 commit 218d518
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/googleCalendarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ export function useGoogleCalendar() {
useEffect(() => {
if (response?.type === 'success') {
const { authentication } = response;
console.log('Logged in with Google:', authentication.accessToken);
setAccessToken(authentication?.accessToken || null);
}
else if (response?.type === 'error') {
console.log('Error during Google login:', response.error);

if (authentication?.accessToken) {
console.log('Logged in with Google:', authentication.accessToken);
setAccessToken(authentication.accessToken);
} else {
console.log('Authentication object is missing or invalid');
setAccessToken(null); // Handle the case when authentication is null or accessToken is undefined
}
} else if (response?.type === 'error') {
console.log('Error during Google login:', response.error);
}
}, [response]);


// Fetch Google Calendar events using the access token
const fetchGoogleCalendarEvents = async () => {
Expand Down

0 comments on commit 218d518

Please sign in to comment.