• Retrieves the current user's Spotify profile

    Returns Promise<SpotifyUserProfile>

    Promise resolving to user profile object

    Error if the request fails

    export async function getCurrentUser(): Promise<SpotifyUserProfile> {
    await ensureValidToken();

    try {
    const response = await retryApiCall(async () => {
    return await spotifyAxios.get(`${API_BASE_URL}/me`, {
    headers: {
    Authorization: `Bearer ${getAccessToken()}`,
    },
    });
    });

    saveLog("Successfully retrieved user profile", "DEBUG");
    return response.data as SpotifyUserProfile;
    } catch (error: unknown) {
    const err = error as Error;
    saveLog(`Failed to get user profile: ${err.message}`, "ERROR");
    throw new Error(`Failed to get user profile: ${err.message}`);
    }
    }