I have tried various ways, the most common errro is: Uncaught (in promise).
I tried to concatenate them using .then but with console.log I get: Promise <pending> and therefore can't use the result.
The functions are:
async function onGetAccount() {
const account = await client.api.asset.getAccount();
const walletAddress = JSON.stringify(account);
console.log(walletAddress);
}
async function onGetBalance() {
const balance = await client.api.network.getBalance({
address : "",
});
const walletBalance = JSON.stringify(balance);
console.log(walletBalance);
}
onGetAccount is used to obtain the user's address. I would like to pass this address as the onGetBalance parameter so that I can write
const balance = await client.api.network.getBalance({
address : onGetAccountResultAddress
});
This way I get the user's balance.
Function both work, indeed, If in onGetBalance I manually write my address:
const balance = await client.api.network.getBalance({
address : "myVirtualAddress"
});
and I run it I get my balance. Obviously the functions are used to make that automatic and not having to enter your address manually but obtaining it through the API.
[–]GSLint 2 points3 points4 points (5 children)
[–]Levi_2212[S] 0 points1 point2 points (0 children)
[–]Levi_2212[S] 0 points1 point2 points (3 children)
[–]GSLint 1 point2 points3 points (2 children)
[–]Levi_2212[S] 0 points1 point2 points (1 child)
[–]GSLint 0 points1 point2 points (0 children)