Scope
React Movie Database is a web app that uses TMDB's API. It's functionality consists of allowing users to sort movies by type and create a favourites list. The goal was to create a React app that utilizes a REST API to display movies through filters and favourite each movie with local storage.
Technologies Used
- React
- Sass
- TMDB API
Development
In the following code snippet, I used React Effect Hook to fetch the movie's API
//Set movie paramaters
const movieId = props.match.params.movieId
//Set State
const [movie, setMovie] = useState([]);
useEffect(() => {
const movieId = props.match.params.movieId;
// fetch the movie API
const fetchMovie = async () => {
const response = await fetch(`$\{API_URL}movie/$\{movieId}?api_key=$\{API_KEY}`);
const data = await response.json();
setMovie(data);
}
fetchMovie();
}, [movie]);