...
/Adding Routes to Get a Single Movie and its Ratings
Adding Routes to Get a Single Movie and its Ratings
Let's learn how to create routes so we can access resources in the database.
We'll cover the following...
In this lesson, we’ll add two more routes—a route to get a specific movie (with its reviews) and a route to get the ratings of all the movies in the database.
MOVIEREVIEWS_DB_URI=mongodb+srv://Cluster09422:XVNEenFBU3N8@cluster09422.yqome88.mongodb.net/sample_mflix?retryWrites=true&w=majority MOVIEREVIEWS_NS=sample_mflix PORT=3000
In the movies.route.js route file, add the two routes shown below:
Line 2: This route retrieves a specific movie and all reviews associated with that movie.
Line 3: This route returns a list of movie ratings (such as G, PG, R) so that a user can select the ratings from a dropdown menu in the frontend.
Retrieving movies by ID and rating
Next, let’s implement the apiGetMovieById and apiGetRatings methods in MoviesController. Add the
following two methods to the movies.controller.js file:
Line 6: We first look for an id parameter, which is the value ...