1
0
cvsa/packages/temp_frontend/app/routes/song/[id]/info.tsx

25 lines
597 B
TypeScript

import useSWR from "swr";
const API_URL = "https://api.projectcvsa.com";
export default function SongInfo() {
const { data, error, isLoading } = useSWR(`${API_URL}/song/[id]/info`, async (url) => {
const response = await fetch(url);
if (!response.ok) {
throw new Error("Failed to fetch song info");
}
return response.json();
});
if (isLoading) return <div>...</div>;
if (error) return <div>: {error.message}</div>;
if (!data) return <div></div>;
return (
<div>
<h1></h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}