It deals with frontend logic required for WebApi of .NET Project
-
VS Code
-
.NET 6.0
-
.NET MVC Template
Created by using following command
dotnet new mvc
-
Code Clean
-
CoinStat API
// CoinStat Controller
[HttpGet]
public async Task<IActionResult> CoinStat_All()
{
var response = await httpClient.GetAsync(Configuration.GetValue<string>("coinstat"));
var content = await response.Content.ReadAsStringAsync();
var Api = new List<Api>();
// if (response.Content.Headers.ContentType.MediaType == "application/json")
// {
Api = JsonConvert.DeserializeObject<List<Api>>(content);
// }
return View(Api);
}
- CoinLore API
// CoinLore Controller
[HttpGet]
public async Task<IActionResult> CoinLore_Individual()
{
var response = await httpClient.GetAsync(Configuration.GetValue<string>("coinlore"));
var content = await response.Content.ReadAsStringAsync();
var Api = new List<Api>();
// if (response.Content.Headers.ContentType.MediaType == "application/json")
// {
Api = JsonConvert.DeserializeObject<List<Api>>(content);
// }
return View(Api);
}
- Final Changes
dotnet run