I am trying to build a netflix clone and on line 12 from the Banner.js file a get the uncaught (in promise) AxiosError. The thing is that the banner doesn't display at all, 'movies' is empty.
Banner.js:
import axios from 'axios';
import React, { useEffect, useState} from 'react'
import requests from "./requests";
function Banner() {
const [movie, setMovie] = useState([]);
useEffect(() => {
async function fetchData() {
const request = await axios.get(requests.fetchNetflixOriginals);
setMovie(
request.data.results[
Math.floor(Math.random() * request.data.results.length -1)
]
);
return request;
}
fetchData();
}, []);
console.log(movie);
return (
<header className="banner"
style={{
backgroundSize: "cover",
backgroundImage: `url(
"https://image.tmdb.org/t/p/original/${movie?.backdrop_path}"
)`,
backgroundPosition: "center center"
}}
>
<div className="banner__contents">
<h1>{movie?.title || movie?.name || movie?.original_name}
</h1>
{/* description */}
</div>
</header>
)
}
export default Banner