Files
Chromacase/front/components/utils/api.tsx
2023-06-17 07:01:23 +01:00

16 lines
471 B
TypeScript

import API from '../../API';
import { SongWithArtist } from '../../models/Song';
export const getSongWArtistSuggestions = async () => {
const nextStepQuery = await API.getSongSuggestions();
const songWartist = await Promise.all(
nextStepQuery.map(async (song) => {
if (!song.artistId) throw new Error('Song has no artistId');
const artist = await API.getArtist(song.artistId);
return { ...song, artist } as SongWithArtist;
})
);
return songWartist;
};