your personal website on atproto - mirror blento.app

Merge pull request #175 from flo-bit/lastfm

fix 522?

authored by Florian and committed by GitHub fc42c99f 8edc0a39

+16 -16
+4 -4
src/lib/cards/media/LastFMCard/LastFMProfileCard/index.ts
··· 21 21 const response = await fetch( 22 22 `https://blento.app/api/lastfm?method=user.getInfo&user=${encodeURIComponent(username)}` 23 23 ); 24 - if (response.ok) { 25 - const result = await response.json(); 26 - allData[`lastfmProfile:${username}`] = result?.user; 27 - } 24 + if (!response.ok) continue; 25 + const text = await response.text(); 26 + const result = JSON.parse(text); 27 + allData[`lastfmProfile:${username}`] = result?.user; 28 28 } catch (error) { 29 29 console.error('Failed to fetch Last.fm profile:', error); 30 30 }
+4 -4
src/lib/cards/media/LastFMCard/LastFMRecentTracksCard/index.ts
··· 21 21 const response = await fetch( 22 22 `https://blento.app/api/lastfm?method=user.getRecentTracks&user=${encodeURIComponent(username)}&limit=50` 23 23 ); 24 - if (response.ok) { 25 - const result = await response.json(); 26 - allData[`lastfmRecentTracks:${username}`] = result?.recenttracks?.track ?? []; 27 - } 24 + if (!response.ok) continue; 25 + const text = await response.text(); 26 + const result = JSON.parse(text); 27 + allData[`lastfmRecentTracks:${username}`] = result?.recenttracks?.track ?? []; 28 28 } catch (error) { 29 29 console.error('Failed to fetch Last.fm recent tracks:', error); 30 30 }
+4 -4
src/lib/cards/media/LastFMCard/LastFMTopAlbumsCard/index.ts
··· 25 25 const response = await fetch( 26 26 `https://blento.app/api/lastfm?method=user.getTopAlbums&user=${encodeURIComponent(username)}&period=${period}&limit=50` 27 27 ); 28 - if (response.ok) { 29 - const result = await response.json(); 30 - allData[`lastfmTopAlbums:${username}:${period}`] = result?.topalbums?.album ?? []; 31 - } 28 + if (!response.ok) continue; 29 + const text = await response.text(); 30 + const result = JSON.parse(text); 31 + allData[`lastfmTopAlbums:${username}:${period}`] = result?.topalbums?.album ?? []; 32 32 } catch (error) { 33 33 console.error('Failed to fetch Last.fm top albums:', error); 34 34 }
+4 -4
src/lib/cards/media/LastFMCard/LastFMTopTracksCard/index.ts
··· 25 25 const response = await fetch( 26 26 `https://blento.app/api/lastfm?method=user.getTopTracks&user=${encodeURIComponent(username)}&period=${period}&limit=50` 27 27 ); 28 - if (response.ok) { 29 - const result = await response.json(); 30 - allData[`lastfmTopTracks:${username}:${period}`] = result?.toptracks?.track ?? []; 31 - } 28 + if (!response.ok) continue; 29 + const text = await response.text(); 30 + const result = JSON.parse(text); 31 + allData[`lastfmTopTracks:${username}:${period}`] = result?.toptracks?.track ?? []; 32 32 } catch (error) { 33 33 console.error('Failed to fetch Last.fm top tracks:', error); 34 34 }