Skip to content
Snippets Groups Projects
Commit e983cab2 authored by Bilel El Yaagoubi's avatar Bilel El Yaagoubi
Browse files

add cast to infos

parent 72a39034
No related branches found
No related tags found
1 merge request!10add cast to infos
Pipeline #42505 passed
......@@ -16,6 +16,7 @@ const MovieSchema = new mongoose.Schema(
video: { type: Boolean },
vote_average: { type: Number },
vote_count: { type: Number },
cast: { type: Array },
},
{
toJSON: { virtuals: true }, // So `res.json()` and other `JSON.stringify()` functions include virtuals
......
......@@ -22,6 +22,11 @@ async function populateMovies(movies) {
// TODO: populate movies into the database
try {
for (const movie of movies) {
const castFetch = await axios.get(
`https://api.themoviedb.org/3/movie/` +
movie.id +
`/credits?api_key=522d421671cf75c2cba341597d86403a`
);
const newMovie = await new MovieModel({
// Movie attributes
adult: movie.adult,
......@@ -38,6 +43,7 @@ async function populateMovies(movies) {
video: movie.video,
vote_average: movie.vote_average,
vote_count: movie.vote_count,
cast: castFetch.data.cast,
});
// Create a new movie instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment