Skip to content

Commit

Permalink
Merge pull request #6 from NayanUnni95/bug
Browse files Browse the repository at this point in the history
fix: api null response error
  • Loading branch information
NayanUnni95 authored Dec 3, 2024
2 parents a9aa36d + d03fbf7 commit 36e4cde
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 36 deletions.
63 changes: 33 additions & 30 deletions src/constants/cleanUpData.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,51 @@ const LikedSongs = (userData) => {
const album = (albumData) => {
if (albumData && albumData.total > 0) {
return albumData.items.map((obj) => {
return {
title: removeCharactersAfterSymbol(obj.album.name),
type: obj.album.type,
image: obj.album.images,
songs: obj.album.tracks.total,
id: obj.album.id,
href: obj.album.href,
items: null,
routePath: obj.album.type,
};
if (obj != null)
return {
title: removeCharactersAfterSymbol(obj.album.name),
type: obj.album.type,
image: obj.album.images,
songs: obj.album.tracks.total,
id: obj.album.id,
href: obj.album.href,
items: null,
routePath: obj.album.type,
};
});
}
};
const playlist = (playlistData) => {
if (playlistData && playlistData.total > 0) {
return playlistData.items.map((obj) => {
return {
title: removeCharactersAfterSymbol(obj.name),
type: obj.type,
image: obj.images,
songs: obj.tracks.total,
id: obj.id,
href: obj.href,
items: null,
routePath: obj.type,
};
if (obj != null)
return {
title: removeCharactersAfterSymbol(obj.name),
type: obj.type,
image: obj.images,
songs: obj.tracks.total,
id: obj.id,
href: obj.href,
items: null,
routePath: obj.type,
};
});
}
};
const artists = (artistsData) => {
if (artistsData && artistsData.artists.total > 0) {
return artistsData.artists.items.map((obj) => {
return {
title: removeCharactersAfterSymbol(obj.name),
type: obj.type,
image: obj.images,
songs: null,
id: obj.id,
href: obj.href,
items: null,
routePath: obj.type,
};
if (obj != null)
return {
title: removeCharactersAfterSymbol(obj.name),
type: obj.type,
image: obj.images,
songs: null,
id: obj.id,
href: obj.href,
items: null,
routePath: obj.type,
};
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function HomeSection() {
// fetchData(`${Several_Albums}{id}`),
// // fetchData(`${Top_Items}`),
// fetchData(`${Single_Artists}{id}`),
fetchData(`${Featured_Playlist}`),
// fetchData(`${Featured_Playlist}`),
// fetchData(`${Several_Tracks}{id}`),
// // fetchData(`${Artists_TopTracks}`),
fetchData(`${New_Release}`),
Expand Down
5 changes: 0 additions & 5 deletions src/pages/Search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ function Search() {
console.log(err);
});
};

useEffect(() => {
console.log(searchCategory);
}, [searchCategory]);

useEffect(() => {
if (!searchCategory) {
fetchData(`${Several_Category}?limit=50`)
Expand Down

0 comments on commit 36e4cde

Please sign in to comment.