• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Does Angular API only call requested data?

Resolved: Does Angular API only call requested data?

0
By Isaac Tonny on 04/04/2023 Issue
Share
Facebook Twitter LinkedIn

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:
Where RecordSummary is:
Now my API endpoint retuns a Full Record:
When I make the call, does the entire Full Record get transferred over the call or just the requested fields? My understanding so far is that it is the full record, but wanted to make sure.

Best Answer:

When you make this call:
You’re specifying that you want to deserialize the JSON you receive and use it as a 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:
This will show an alert with the Age that was received from the API.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

angular api c#
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to stop a thread that has a blocking function from easygui in python

05/04/2023

Resolved: Removing null keys from a json array of objects

05/04/2023

Resolved: How can I generate at compile-time a separate OpenAPI Swagger.json file for each Controller in my ASP.NET project?

05/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.