I am trying to call a web API from my web application. I am using .Net 5.0 and while writing the code I am getting the error:
"The name 'JsonConvert' does not exist in the current "definition JsonConvert.DeserializeObject method.
So my question is what's the @inject...
I need to use in order to use in razor page
@code {
private Employee Employee{ get; set; } = new Employee();
private async void HandleValidSubmit()
{
try
{
var response = await Http.PostAsJsonAsync("/api/Employee", Employee);
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
var employee= JsonConvert.DeserializeObject<Employee>(content);
Navigation.NavigateTo($"employee/edit/{employee.Id}");
}
catch (AccessTokenNotAvailableException exception)
{
exception.Redirect();
}
catch (Exception e)
{
}
}
}