public async Task OnGetAsync() { var hc = _httpClientFactory.CreateClient(); var res = await hc.GetStringAsync(_configuration["Patreon:GoalApiUrl"]); Goal = JsonSerializer.Deserialize <PatreonGoal>( JsonDocument.Parse(res).RootElement .GetProperty("data") .GetProperty("attributes") .GetRawText() ); }
public async Task <IViewComponentResult> InvokeAsync() { var currentGoal = new PatreonGoal(); try { currentGoal = await _patreonApiHelper.GetCurrentGoalAsync(); } catch (Exception ex) { _logger.LogError($"Error while loading patreon goals: {ex.Message}"); } return(View(currentGoal)); }