Fetch All Movies
Learn to implement a controller that fetches movie data from MongoDB.
Getting all the movies
A user should be able to see all the movies they can review. To accomplish this, we must create a GET
request. This simple request will retrieve all the movies to be reviewed from the movie collection. We don’t need to pass any body parameters here; we only need to ensure the user is authenticated. Furthermore, there’s no authorization check in place.
Setting up the controllers
Next, we have to create a controller that interacts with the routes. The GetMovies()
controller will return all the movies in the collection and the total number of movies in the collection.
Get hands-on with 1200+ tech skills courses.