I am using Microsoft.AspNetCore.Blazor.HttpClient to perform requests on my API endpoints.
If the below call finds nothing it raises an exception.
using var client = auth.GetMyToken();
return await Task.Run(async () => await client.GetJsonAsync<MyModel>($"getsomething/{id}"));
The error says:
{"The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0."}
I am guessing it does this because the return is not JSON (it's nothing)
I'd rather not wrap a Try{}
block around it to deal with no records found.
How can I amend this to return null (or an empty model) if no record is found?