In my web api when i run project for get data from database got this error .net core 3.1
JsonException: A possible object cycle was detected which is not
I have the same issue, my fix was to add async and await keyword since I am calling an async method on my business logic.
Here is my original code:
[HttpGet]
public IActionResult Get()
{
//This is async method and I am not using await and async feature .NET which triggers the error
var results = _repository.GetAllDataAsync();
return Ok(results);
}
To this one:
HttpGet]
public async Task Get()
{
var results = await _repository.GetAllDataAsync();
return Ok(results);
}