I have a task to retrieve data from endpoint webapi and display it to View. The external website developers provided me with 2 endpoints.
The 1st endpoint is a list of data and only has got : id, name and year; the second one is per item (fetch by its Id) and has more and more data details that I need to use.
So far, I'm able to call the 1st endpoint and retrieve the all list and pass it on to view... but after a while I realized that I need to also call each endpoint item by its id to retrieve the whole details for each item... and to accomplish the later I need to call a second webapi by its Id.
So my idea so far is : I need to call two webapi. The first one to get the list of id, then call the second webapi and use the already retrieved list of id from the first webapi call to get every single item and their details; cause I cannot directly call the webapi by id as the list is dynamic from external site and can change anytime from the external web server. So I need first to retrieve the list.
I just need idea from you please and possibly sample code about what to do !!!
or If it's a good idea to call a second webapi.
-- I also notice a latency while calling webapi, also learn that jquery is fast.--
The App workflow is as follow : In WebSite A, when a user click a button named "Vehicle" it must call webapi from website B to get data, and display those data in a page in website A. So there's no user interaction for each item from website A. I need to retrieve the all >list + details.
Below is my endpoint call to get the whole list.
HttpClient client = new HttpClient();
string APIdatas = null;
HttpResponseMessage response = await client.GetAsync("https://jsonplaceholder.typicode.com/todos/");
if (response.IsSuccessStatusCode)
{
APIdatas = await response.Content.ReadAsStringAsync();
}
var stringJson = JsonConvert.DeserializeObject<List<CrowdfundingViewModel>>(APIdatas);
return View(stringJson);