Advertisement
Guest User

netflix clone code

a guest
May 11th, 2021
1,623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const base_url = "https://image.tmbd.org/t/p/original";
  2.  
  3. function Row({title, fetchUrl}) {
  4.     const [movies, setMovies] = useState([]);
  5.  
  6.     useEffect(() => {
  7.         // if[], run once when the row loads, and don't run again
  8.         async function fetchData(){
  9.             const request = await axios.get(fetchUrl);
  10.             setMovies(request.data.results);
  11.             console.log(request.data.results);
  12.             return request;
  13.         }
  14.         fetchData();
  15.     }, [fetchUrl]);
  16.  
  17.     return(
  18.         <div className="row">
  19.             <h2>{title}</h2>
  20.  
  21.             <div className="row_posters">
  22.                 {movies.map(movie => (
  23.                     <img src={`${base_url}${movie.poster_path}`} alt={movie.name}/>
  24.                 ))}
  25.             </div>
  26.         </div>
  27.     )
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement