In this post, we will see how to resolve Does Angular API only call requested data?
Question:
I am making an api call and want make sure I am reducing data transfer as much as possible.on the Angular end I have a request:
RecordSummary
is:Full Record
:Best Answer:
When you make this call:RecordSummary
object. It does not communicate this object structure to the API, so you will still be receiving the full object that the API sends.You can confirm this by looking at the network request in your browser’s developer tools window. For Chrome you can open this by pressing F12.
Please also note that you’re dealing with TypeScript which still gets converted to JavaScript when you “build” it, so although your statically typed code has a
RecordSummary
object, the actual object in-memory will have more data in it if the API sent more. You can observe this by casting it to any
and then accessing one of the properties:If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com