I would like to read information from the LocalStorage within a .razor file and then execute further source code on the basis of this. The problem is that he doesn't wait when reading from the LocalStorage.
@{
var loggedIn = IsLoggedIn();
if (loggedIn.Result)
{
// do something
}
}
private async Task<bool> IsLoggedIn()
{
var result = await LocalStorage.GetAsync<Account>("AccountInfo");
_account = result.Value;
return string.IsNullOrEmpty(_account?.Name);
}
As soon as it reaches the "await LocalStorage.GetAsync" and I continue using debugger, "if (loggedIn.Result)" is called without waiting for the result of the await.
What could be the reason?
Best regards and thank you for ideas.