79483382

Date: 2025-03-04 10:36:38
Score: 0.5
Natty:
Report link

Resolved it myself

OnInitializedAsync() was trying to call an API that wasn't async. This resulted in the JSON object I returned was empty when it mattered.

Before:

app.MapGet("/api/blob", (IBlobService blobService) => blobService.GetStrings());
app.MapGet("/api/sql", (ISqlService repo) =>
{
    var sqlDiners =  repo.GetLastestDiners();
    return sqlDiners is not null
        ? Results.Ok(sqlDiners)
        : Results.NotFound("No customers found.");
});

After:

app.MapGet("/api/blob", async (IBlobService blobService) => await blobService.GetStrings());
app.MapGet("/api/sql", async (ISqlService repo) =>
{
    var sqlDiners =  await repo.GetLastestDiners();
    return sqlDiners is not null
        ? Results.Ok(sqlDiners)
        : Results.NotFound("No customers found.");
});
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Mikkel Rohde Glerup