import * as serverApi from '../../api/api'; import { GetArtistResponse } from '../../api/api'; import backendRequest from './request'; export async function getArtist(id: number): Promise { if (isNaN(id)) { throw new Error("Cannot request a NaN artist."); } const response = await backendRequest((process.env.REACT_APP_BACKEND || "") + serverApi.GetArtistEndpoint.replace(':id', `${id}`)) if (!response.ok) { throw new Error("Response to artist request not OK: " + JSON.stringify(response)); } return await response.json(); }