OnInitializedAsync I get a list of my customers with an http request. It will load one item to the list. How can I get this item to my other variable? Code below.
private List<CustomerDTO> customers { get; set; }
private CustomerDTO customer { get; set; } = new();
protected override async Task OnInitializedAsync()
{
customers = await httpClient.GetFromJsonAsync<List<CustomerDTO>>(TestRoutes.Customer.GET_Customers());
customer = ?
}
After clarification in the comments I tried to use customer = customers.FirstOrDefault(x => x.Id == <insert Id here>);
Of course I had no Id to compare. So as @John mentioned in the comments, I used customer = customers.First();
to get that single customer from the List