Files
swingmusic-extended/src/composables/fetch/artists.ts
T
geoffrey45 580dce1da9 attach artist page link to ArtistName component
+ separate fetching artist albums with fetching artist info
+ include limit when fetching artist albums
+ refactor interfaces
2023-01-13 18:13:49 +03:00

37 lines
740 B
TypeScript

import { paths } from "@/config";
import useAxios from "./useAxios";
import { Artist, Track, Album } from "@/interfaces";
const getArtistData = async (hash: string) => {
interface ArtistData {
artist: Artist;
tracks: Track[];
}
const { data, error } = await useAxios({
get: true,
url: paths.api.artist + `/${hash}`,
});
if (error) {
console.error(error);
}
return data as ArtistData;
};
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 };