I actually make two calls from the same API to get the same data. One from the parent component and one from the child component.
This is the way I get my data in parent.js
and child.js
...
this.cyclistService.cyclistInfo().subscribe(
(cyclist) => {
this.cyclist = cyclist
}
)
...
In order to reduce network latency, should I make the API call in both places or just pass the data locally ?
I post the answer given from ryan-m, which might help someone else who has the same question.
«Just pass the data locally. Redundant API calls are always going to be slower because network latency on a phone is potentially a lot, and you could have one fail but not the other, and all sorts of fun things to think about. Reducing the number of API calls you need to make from a mobile device is always good if you have a way to do it without sacrificing correctness. »