Hi I am using first time view Component in my Dotnet core application to get API result data to view. I have created a class and calling await API call but view render early and not wait for api response.
namespace Gut.Web.Components
{
public class OneWayResultViewComponent : ViewComponent
{
#region Fields
private readonly IApiAggregatorService _apiAggregatorService;
private readonly IWorkContext _workContext;
private readonly ITravelApiProviderService _travelApiProviderService;
#endregion
#region Ctor
public OneWayResultViewComponent(IApiAggregatorService apiAggregatorService, IWorkContext workContext, ITravelApiProviderService travelApiProviderService)
{
_apiAggregatorService = apiAggregatorService;
_workContext = workContext;
_travelApiProviderService = travelApiProviderService;
}
#endregion
#region Methods
public async Task<IViewComponentResult> InvokeAsync(string sessionid)
{
var searchFlightDetails = await _apiAggregatorService.GetCacheSearchFlightDetailsByIdAsync(sessionid);
var travelers = _travelApiProviderService.GetActiveProvider();
var response = _apiAggregatorService.SearchOneWay(travelers, searchFlightDetails).Result;
return View(response);
}
public override
#endregion
}
}
so I need to show response to view. I have search on google but didn't find a way to reupdate component. Example found to call component by jQuery. If jQuery is required so I can call partialview then why component.