From 83fa86cf15ef2dc64828baed08a438a5d14460ce Mon Sep 17 00:00:00 2001 From: pu098 Date: Wed, 31 Jan 2024 14:43:56 +0700 Subject: [PATCH] debugging beatbuddy --- src/beatbuddy/src/spotify/getSong.ts | 3 +++ src/beatbuddy/src/spotify/spotifyAuth.ts | 8 ++++---- src/components/Navbar.tsx | 4 ++-- src/components/SongResult.tsx | 1 - 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/beatbuddy/src/spotify/getSong.ts b/src/beatbuddy/src/spotify/getSong.ts index 71695015..0ab94e0a 100644 --- a/src/beatbuddy/src/spotify/getSong.ts +++ b/src/beatbuddy/src/spotify/getSong.ts @@ -17,6 +17,9 @@ export async function playSong(trackId: string) { const spotifyClient: SpotifyWebApi = await getSpotifyClient(); + const accessToken = spotifyClient.getAccessToken(); + console.log('Access Token playSong:', accessToken); + // Retrieve the preview URL for the track const response = await fetch(`https://api.spotify.com/v1/tracks/${trackId}`, { headers: { diff --git a/src/beatbuddy/src/spotify/spotifyAuth.ts b/src/beatbuddy/src/spotify/spotifyAuth.ts index 5886b297..661db28e 100644 --- a/src/beatbuddy/src/spotify/spotifyAuth.ts +++ b/src/beatbuddy/src/spotify/spotifyAuth.ts @@ -7,10 +7,10 @@ const REDIRECT_URI = process.env.REACT_APP_SPOTIFY_REDIRECT_URI_PROD; const AUTHORIZATION_ENDPOINT = 'https://accounts.spotify.com/authorize'; const TOKEN_ENDPOINT = 'https://accounts.spotify.com/api/token'; -const SCOPE = 'user-read-private \ - playlist-modify-public \ - playlist-modify-private \ - streaming'; +const SCOPE = `user-read-private + playlist-modify-public + playlist-modify-private + streaming`; /** * Redirects the user to the Spotify Accounts service to authorize access diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 241f2bc2..628330a4 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -16,10 +16,10 @@ function Navbar() { useEffect(() => { const checkCookieCleared = () => { if (!document.cookie.includes('spotify_access_token')) { - console.log('cookie is cleared') + // console.log('cookie is cleared') setCookieCleared(true); } else { - console.log('cookie is not cleared') + // console.log('cookie is not cleared') setCookieCleared(false); } }; diff --git a/src/components/SongResult.tsx b/src/components/SongResult.tsx index 5577641e..dee3d8a5 100644 --- a/src/components/SongResult.tsx +++ b/src/components/SongResult.tsx @@ -22,7 +22,6 @@ function SongResult(props: any) { // This useEffect handles the play/pause btn when users changes song useEffect(() => { - console.log('currTrackId changes: ' + props.currTrackId); if (props.currTrackId === props.id) { setPlayPauseBtn(pause_btn); } else {