diff --git a/frontend/src/app/album/[id]/page.tsx b/frontend/src/app/album/[id]/page.tsx new file mode 100644 index 0000000..8803179 --- /dev/null +++ b/frontend/src/app/album/[id]/page.tsx @@ -0,0 +1,29 @@ +'use client' + +import { useState, useEffect } from 'react' +import { Album } from '@/common/album.entity'; +import { useParams } from 'next/navigation' + +export default function Page() { + const [album, setAlbum] = useState(); + + const params = useParams<{ id: string }>(); + const id = params.id; + + useEffect(() => { + async function fetchAlbum(id: string) { + const response = await fetch(`https://api.anatid.net/album/${id}`); + const data = await response.json(); + setAlbum(data); + } + fetchAlbum(id); + }, [id]); + + if (!album) return
Loading...
+ + return ( + + ); +} diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index c5b8468..be15206 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -1,13 +1,27 @@ +'use client' + +import { useState, useEffect } from 'react' import { Album } from '@/common/album.entity'; -export default async function Page() { - const data = await fetch('https://api.anatid.net/album') - const albums = await data.json() +export default function Page() { + const [albums, setAlbums] = useState([]); + + useEffect(() => { + async function fetchAlbums() { + const response = await fetch('https://api.anatid.net/album'); + const data = await response.json(); + setAlbums(data); + } + fetchAlbums() + }, []); + + if (!albums) return
Loading...
+ return ( - ) + ); }