So the object shared was just a mock up. This is from an application I built.
The code that displays the movie-cards(displayed objects):
// Movie card component
function MovieCard ({ movies, movie, user, updateUser }) {
const [inFavoriteMovies, setInFavoriteMovies] = useState(user && user.FavoriteMovies.includes(movie._id));
const token = window.localStorage.getItem("token");
// add Fav Movie function
const addFavoriteMovie = () => {
fetch(`https://movies-couch-api.vercel.app/users/${user.Username}/favMovies/${movie._id}`, {
method: "POST",
headers: {Authorization: `Bearer ${token}`}
})
.then(response => {
if (response.ok) {
return response.json();
} else {
alert("Failed adding the Movie to Favorite Movies");
return false;
}
})
.then(user => {
if(user) {
alert("Movie added to Favorite Movies");
setInFavoriteMovies(true);
updateUser(user);
}
})
.catch(e => {
alert(e);
console.log(e);
});
}
// Remove-favMovies
const removeFavoriteMovie = () => {
fetch(`https://movies-couch-api.vercel.app/users/${user.Username}/favMovies/${movie._id}`, {
method: "DELETE",
headers: {Authorization: `Bearer ${token}`}
})
.then(response => {
if (response.ok) {
return response.json();
} else {
alert("Failed removing movie from Favorite list");
return false;
}
})
.then(user => {
if(user) {
alert("Movie deleted from Favorite Movies");
setInFavoriteMovies(false);
updateUser(user);
}
})
.catch(e => {
console.log(e);
alert(e);
});
}
return (
<Card className="movie-card" style={{ width:"18rem"}}>
<Card.Img variant="top" src={movie.ImageURL} alt="movie-poster"/>
<Card.Body className="movie-card-body">
<Card.Title>{movie.Title}</Card.Title>
<Card.Text>
<br /><br />
{movie.Director.Name}
<br /><br />
{movie.Genre.Name}
</Card.Text>
<br />
<Link to={`/movies/${encodeURIComponent(movie._id)}`}>
<Button className="movie-card-button" variant="outline-warning">Open</Button>
<br/> <br/>
{inFavoriteMovies ? <Button onClick={(e) => {
e.preventDefault();
removeFavoriteMovie(movie._id);
}}
className="movie-card-button" variant="outline-warning"
>Remove from Favorite Movies</Button> :
<Button onClick={(e) => {
e.preventDefault();
console.log(movie._id);
addFavoriteMovie(movie._id);
}}
className="movie-card-button" variant="outline-warning"
>Add to Favorite Movies</Button>
}
</Link>
</Card.Body>
</Card>
);
example of the movies (object)
this does not render the director object
{
_id: ObjectID("6378afed9eda6047940371ec"),
Description: "The Lord of the Rings: The Fellowship of the Ring is a 2001 epic fantasy adventure film directed by Peter Jackson from a screenplay by Fran Walsh, Philippa Boyens, and Jackson, based on 1954s The Fellowship of the Ring, the first volume of the novel The Lord of the Rings by J. R. R. Tolkien. The film is the first installment in The Lord of the Rings trilogy. It features an ensemble cast including Elijah Wood, Ian McKellen, Liv Tyler, Viggo Mortensen, Sean Astin, Cate Blanchett, John Rhys-Davies, Billy Boyd, Dominic Monaghan, Orlando Bloom, Christopher Lee, Hugo Weaving, Sean Bean, Ian Holm, and Andy Serkis. Set in Middle-earth, the story tells of the Dark Lord Sauron, who seeks the One Ring, which contains part of his might, to return to power. The Ring has found its way to the young hobbit Frodo Baggins. The fate of Middle-earth hangs in the balance as Frodo and eight companions (who form the Fellowship of the Ring) begin their journey to Mount Doom in the land of Mordor, the only place where the Ring can be destroyed.",
Title: "The Lord of the Rings: The Fellowship of the Ring",
Director: {
Bio: ’"Peter Jackson is a New Zealand film director, screenwriter and producer. He is best known as the director, writer and producer of the Lord of the Rings trilogy (2001–2003) and the Hobbit trilogy (2012–2014), both of which are adapted from the novels of the same name by J. R. R. Tolkien.",
Name: "Peter Jackson",
Birthdate: "31-10-1961" ,
Deathdate: "not available" },
Genre: {
Name: "epic fantasy " ,
Description: "Epic fantasy is a subgenre of fantasy defined by the epic nature of its setting or by the epic stature of its characters, themes, or plot. The term 'high fantasy' was coined by Lloyd Alexander in a 1971 essay, 'High Fantasy and Heroic Romance', which was originally given at the New England Round Table of Children's Librarians in October 1969."},
ImageURL: "https://www.themoviedb.org/t/p/w600_and_h900_bestv2/6oom5QYQ2yQTMJIbnvbkBL9cHo6.jpg"
}
this object does render perfect-
{
_id: ObjectID("6378b0b2a51c9e2ddc6f79bd"),
Description: "The Lord of the Rings: The Return of the King is a 2003 epic fantasy adventure film directed by Peter Jackson from a screenplay by Fran Walsh, Philippa Boyens, and Jackson, based on 1955s The Return of the King, the third volume of the novel The Lord of the Rings by J. R. R. Tolkien. Continuing the plot of the previous film, Frodo, Sam and Gollum are making their final way toward Mount Doom in Mordor in order to destroy the One Ring, unaware of Gollums true intentions, while Merry, Pippin, Gandalf, Aragorn, Legolas, Gimli and the rest are joining forces together against Sauron and his legions in Minas Tirith. The Return of the King was financed and distributed by American studio New Line Cinema, but filmed and edited entirely in Jacksons native New Zealand, concurrently with the other two parts of the trilogy. It premiered on 1 December 2003 at the Embassy Theatre in Wellington and was theatrically released on 17 December 2003 in the United States, and on 18 December 2003 in New Zealand.",
Title: "The Lord of the Rings: The Return of the King",
Director: {
Bio: ’"Peter Jackson is a New Zealand film director, screenwriter and producer. He is best known as the director, writer and producer of the Lord of the Rings trilogy (2001–2003) and the Hobbit trilogy (2012–2014), both of which are adapted from the novels of the same name by J. R. R. Tolkien.",
Name: "Peter Jackson",
Birthdate: "31-10-1961" ,
Deathdate: "not available" },
Genre: {
Name: "epic fantasy " ,
Description: "Epic fantasy is a subgenre of fantasy defined by the epic nature of its setting or by the epic stature of its characters, themes, or plot. The term 'high fantasy' was coined by Lloyd Alexander in a 1971 essay, 'High Fantasy and Heroic Romance', which was originally given at the New England Round Table of Children's Librarians in October 1969."},
ImageURL: "https://www.themoviedb.org/t/p/w600_and_h900_bestv2/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg"
}
Additionally I do not have actors in the object.