From 8a38d0ecc1c7f8e4b09796bc99d89e5b78b104cc Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Tue, 9 Sep 2025 01:46:32 -0400 Subject: [PATCH] fix music --- src/components/MusicComponent.tsx | 21 +++++++++++++-------- src/utils/types.ts | 11 ++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/MusicComponent.tsx b/src/components/MusicComponent.tsx index 0f5f397..9b88b30 100644 --- a/src/components/MusicComponent.tsx +++ b/src/components/MusicComponent.tsx @@ -7,11 +7,16 @@ export default function MusicComponent() { useEffect(() => { async function fetchMusic() { - const response = await fetch("https://api.alexav.gg/v4/social/music"); - if (response.ok) { - const data = await response.json(); - setMusic(data.data.tracks[0] as LastFMMusicObject); - } else setFailedFetch(true); + try { + const response = await fetch("https://api.alexav.gg/v4/social/music"); + if (response.ok) { + const data = await response.json(); + setMusic(data.data as LastFMMusicObject); + } else setFailedFetch(true); + } catch (e) { + console.error("Failed to fetch music!", e); + setFailedFetch(true); + } } setTimeout(() => { @@ -23,10 +28,10 @@ export default function MusicComponent() { if (music) { return (
- +
-

{music.name}

-

{music.artist["#text"]}

+

{music.title}

+

{music.artist}

); diff --git a/src/utils/types.ts b/src/utils/types.ts index fbdb4cc..a031fae 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,15 +1,12 @@ type LastFMMusicObject = { - artist: { - mbid: string; - "#text": string; - }; - name: string; - image: LastFMImageObject[]; + artist: string; + title: string; + images: LastFMImageObject[]; url: string; }; type LastFMImageObject = { size: "small" | "medium" | "large" | "extralarge"; - "#text": string; + url: string; }; // nfl stuff