I am developing a react app with a movie API (https://developers.themoviedb.org). The thing is that i am trying to put information from the API in a card. I use useState
and useEffect
for this. Also, I use Axios to bring it from the API. I don't know, I can't see what is not working. The error message is map is not a function but also, I believe that is something wrong in my useEffect
. Please help!
const Home = () => {
const [movies, setMovies] = useState([]);
useEffect(() => {
axios.get("https://api.themoviedb.org/3/trending/movie/week?api_key=**APIKEY**")
.then(res => {
setMovies(res.data);
}).catch(console.log)
},
[]
);
return (
<section id="main-page">
<div className='list-main-page'>
<a href='#'>
<h2>
Películas que son tendencia
<FontAwesomeIcon className='arrow-list' icon={faArrowRight} />
</h2>
</a>
<div className='card-list-container'>
{movies.map((movie, i) => {
return (
<Card key={i} image={movie.poster_path} />
)})
}
</div>
</div>
</section>
)
};
export default Home;