Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const base_url = "https://image.tmbd.org/t/p/original";
- function Row({title, fetchUrl}) {
- const [movies, setMovies] = useState([]);
- useEffect(() => {
- // if[], run once when the row loads, and don't run again
- async function fetchData(){
- const request = await axios.get(fetchUrl);
- setMovies(request.data.results);
- console.log(request.data.results);
- return request;
- }
- fetchData();
- }, [fetchUrl]);
- return(
- <div className="row">
- <h2>{title}</h2>
- <div className="row_posters">
- {movies.map(movie => (
- <img src={`${base_url}${movie.poster_path}`} alt={movie.name}/>
- ))}
- </div>
- </div>
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement