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 trialmark lefler
2,662 Points(data.message) question
I know the data is the data from the fetch request but what is the "message" part?
1 Answer
Travis Alstrand
Treehouse Project ReviewerThe message
property on the object returned from the api (which we've given the name data
to) is what holds the list of breed names in this situation. It's a property that the creators of the api specifically made / named for that purpose, so other apis may name it something different, that's why it's always important to read the documentation on an api you'd like to work with.
Like Guil has done with fetch()
in the video here, if you just type
https://dog.ceo/api/breeds/list
into your browser and submit that, you'll see the JSON response (I use Chrome and the JSONview extension which helps make it more readable) and you'll see the layout of the response clearly.
Of course, if you're following / coding along with the video or ever using an api with fetch
you can console.log it like so
fetch("https://dog.ceo/api/breeds/list")
.then(response => respose.json())
.then(data => console.log(data));
I hope that helps and makes sense!