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 trialjlampstack
23,932 PointsI don't understand response.data @3:45
Instructor doesn't explain response.data, just simply plugs it in. Where is .data coming from? Is it a built-in Angular method? What is it's purpose?
2 Answers
Ryan S
27,276 PointsHi Jay,
When calling Angular's $http.get() method, the server will respond with a 'response' object, provided the request was successful.
This 'response' object has a few properties that you can access, one of which is "data". This data property will contain the data of the response, i.e., the JSON object that you had requested from the server.
Other properties of the response object are: config, headers, status, and statusText which can be accessed in the same way as the data.
Hope this clears things up.
olu adesina
23,007 Pointsthis is extremely helpful thanks @jaycode and ryan s
jlampstack
23,932 Pointsjlampstack
23,932 PointsThank you, was reading up on it. The response from the server is an object that has properties. data is just one of the properties it has. I've posted a link for more info and properties.
https://www.w3schools.com/angular/angular_http.asp