Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCaleb Hasch
Full Stack JavaScript Techdegree Graduate 16,351 PointsThe director only returns "[object]"
So I have my people alias set up just like in the example, but all I'm getting back for Brad is
{
id: 1,
firstName: 'Brad',
lastName: 'Bird',
director: [ [Object], [Object] ]
},
Why is it like that and how do I get the actual movie objects to show?
1 Answer
Lee Vaughn
Treehouse TeacherHey Caleb!
When you are retrieving and logging out people
are you using console.log(people.map(person => person.get({ plain: true })));
or console.log(JSON.stringify(people, null, 2));
? The first option typically returns [ [Object], [Object] ]
as you are describing but the second option should log out:
director": [
{
"id": 2,
"title": "The Incredibles",
"releaseYear": 2004,
"directorPersonId": 1
},
{
"id": 1,
"title": "The Iron Giant",
"releaseYear": 1999,
"directorPersonId": 1
}
]
If you continue to run into trouble go ahead and share a link to your code and we can dig a little deeper.
PS: Since you are in the FSJS Techdegree you should consider reaching out in Slack with questions like these. You can find a link to Slack on the right side of the Home page.