Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.4 kB
2
Indexable
Never
import React, { useEffect, useState } from "react";

const Detail = ({ match }) => {
    const { movieId } = match.params;
    const [movieDetails, setMovieDetails] = useState(null);

    useEffect(() => {
        const fetchMovieDetails = async () => {
            const options = {
                method: 'GET',
                headers: {
                    accept: 'application/json',
                    Authorization: 'Bearer YOUR_TOKEN'
                }
            };

            try {
                const response = await fetch('https://api.themoviedb.org/3/movie/'+movieId+'?language=fr-FR', options);
                const data = await response.json();
                setMovieDetails(data);
            } catch (err) {
                console.error(err);
            }
        };

        fetchMovieDetails();
    }, [movieId]);

    return (
        <div className="detail">
            <div>
                {movieDetails ? (
                    <div>
                        <p>ID du Film : {movieId}</p>
                        {/* Autres détails du film ici */}
                    </div>
                ) : (
                    <p>Chargement des détails du film...</p>
                )}
            </div>
            {/* Autres éléments de l'interface ici */}
        </div>
    );
}

export default Detail;
Leave a Comment