attach artist page link to ArtistName component

+ separate fetching artist albums with fetching artist info
+ include limit when fetching artist albums
+ refactor interfaces
This commit is contained in:
geoffrey45
2022-12-05 18:27:55 +03:00
committed by Mungai Njoroge
parent e54fea2d4d
commit 580dce1da9
14 changed files with 162 additions and 53 deletions
+15 -5
View File
@@ -5,22 +5,32 @@ import { Artist, Track, Album } from "@/interfaces";
const getArtistData = async (hash: string) => {
interface ArtistData {
artist: Artist;
albums: Album[];
tracks: Track[];
}
const { data, error } = await useAxios({
get: true,
url: paths.api.artist + `/${hash}?limit=6`,
url: paths.api.artist + `/${hash}`,
});
if (error) {
console.error(error);
}
console.log(data);
return data as ArtistData;
};
export { getArtistData };
const getArtistAlbums = async (hash: string, limit = 6) => {
const { data, error } = await useAxios({
get: true,
url: paths.api.artist + `/${hash}/albums?limit=${limit}`,
});
if (error) {
console.error(error);
}
return data.albums as Album[];
};
export { getArtistData, getArtistAlbums };