Rositsa Ruseva

Rositsa Ruseva

  • 1.5k
  • 218
  • 31.9k

Failed to load data from the database

Jun 8 2024 7:36 PM

I do have a Blazor App with a Product Page. There are some products in the database that I do want to display when the Products tab is selected. However the products are not displayed.

However on LoadProducts i could not get anything from res.Value, there is no such thing. How to get the list on LoadProducts method?

private async Task LoadProducts()
    {

        try
        {
                var response = await ProductController.GetAllProducts();

                var res = response.Result;
                if (response.Value != null)
                {
                    ProductsList = response.Value;
                }
            else
            {
                throw new Exception("Error: Unable to retrieve products.");
            }
        }
        catch (Exception ex)
        {
            throw new Exception($"Error loading products: {ex.Message}");
        }
    }


Answers (4)