aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Genre.tsx
blob: e63a26a4b5d307113425e25d285cda4f7ae42b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { useEffect, useState } from "react"

const Genres = ({id}) => {

    const baseURL = 'https://api.themoviedb.org/3'
    const API_KEY = '8216fbb9997cd81a67471e6cb5a6f2df'
    const [genres, setGenres] = useState()

    useEffect(() => {
        fetch(`${baseURL}/movie/${id}?api_key=${API_KEY}`).then((res) => res.json()).then((data) => {
            console.log('MOVIE', data.genres)
            setGenres(data.genres)
        })
    }, [])

    return (
        <div className="text-white/60 gap-x-3 text-xs flex flex-row flex-wrap relative">
            {genres?.map((genre) => {
                return (
                    <div>{genre.name}</div>
                )
            })}
        </div>
    )
}

export default Genres