Spotify track ID to remove
Whether to suppress error logs
Promise resolving to true if successful
export async function unlikeTrack(
trackId: string,
silent: boolean = false,
): Promise<boolean> {
await ensureValidToken();
try {
await retryApiCall(async () => {
await spotifyAxios.delete(`${API_BASE_URL}/me/tracks?ids=${trackId}`, {
headers: {
Authorization: `Bearer ${getAccessToken()}`,
},
});
});
if (!silent) {
saveLog(`Track ${trackId} removed from library`, "INFO");
}
return true;
} catch (error: unknown) {
const err = error as Error & AxiosErrorResponse;
if (!silent) {
saveLog(`Failed to remove track from library: ${err.message}`, "ERROR");
}
return false;
}
}
Removes a track from the user's Spotify library