Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AngularJS Basics (1.x) Services in Angular Using Services To Get Data

I 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
Ryan S
27,275 Points

Hi 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.

Thank 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.


olu adesina
olu adesina
23,007 Points

this is extremely helpful thanks @jaycode and ryan s