mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
580dce1da9
+ separate fetching artist albums with fetching artist info + include limit when fetching artist albums + refactor interfaces
37 lines
740 B
TypeScript
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 };
|