My Blazor component looks like this:
<input type="text" @bind-value="@MyText" @bind-value:event="oninput" />
@code {
private String myText;
protected String MyText
{
get { return myText; }
set
{
myText = value;
//await GetMyHttp();
}
}
private async Task GetMyHttp()
{
HttpClient Http = _httpClientFactory.CreateClient("MyId");
myData = await Http.GetFromJsonAsync<MyData>("MyParams");
}
}
And this works fine. But if I uncomment the await GetMyHttp(); line,
I get this compilation error:
Error CS4033 The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
How do I refactor this code to await the async method when the user types in the text box?