Skip to content

Commit

Permalink
log data in last.fm api so i can see why fail in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
jackharrhy committed Feb 15, 2025
1 parent 6be72c5 commit b4417a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion site/src/pages/tools/lastfm/now-playing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ let error = null;
// TODO cache this via Astro db, if we've updated in the last 30 seconds, don't fetch again
let data;
try {
const url = new URL("https://ws.audioscrobbler.com/2.0/");
url.search = new URLSearchParams({
Expand All @@ -21,14 +23,15 @@ try {
}).toString();
const response = await fetch(url);
const data = await response.json();
data = await response.json();
const tracks = data.recenttracks.track;
if (tracks.length > 0 && tracks[0]["@attr"]?.nowplaying) {
currentTrack = tracks[0];
}
} catch (err) {
console.error(err);
console.error(data);
error = "Failed to fetch now playing data";
}
Expand Down

0 comments on commit b4417a2

Please # to comment.