api is returning empty Array

Viewed 46
2 Answers
[Route("api/[controller]")]
[ApiController]
public class AnimalsController : ControllerBase
{
    public IActionResult GetAnimals()
    {
        var animals = new List<AnimalModel> 
        {
            new AnimalModel() { Name = "dog", Description = "4 legs"},
            new AnimalModel() { Name = "cat", Description = "4 legs" }
        };
        return Ok(animals);
    }
}

public class AnimalModel
{
    public string Name { get; set; }
    public string Description { get; set; }
}

enter image description here

  • remove the semicolon in line 13
  • remove the semicolon in line 15, and 16 add (comma),

then try to execute it

Related