I'm facing an issue with a Javascript function that is supposed to return a string. Despite confirming that the JS function does return a string, the corresponding C# part always ends up null.
Below is the snippet of the Javascript function:
window.get_current_user = () => {
Moralis.User.currentAsync().then(function (user) {
var wallet = user.get('ethAddress');
return wallet;
});
}
This is how the C# code calls it:
private async void GetAddress()
{
var userAddress = await _js.InvokeAsync<string>("get_current_user");
_js.InvokeVoidAsync("alert", userAddress);
}
Despite using Chrome Dev Console dev tools to verify that the correct value is being returned by the JavaScript function as a string, https://i.sstatic.net/tlTMR.png.
To further investigate, I placed a breakpoint on the 4th line of the GetAddress function and noticed that the value of 'userAddress' is, in fact, null. https://i.sstatic.net/jyqly.png.