Hi Tomas, thank you so much for you answer. I’ve checked the documentation and I’ve tried to write the code I need but unsuccessfully. I’m super beginner in programming but unlike other api call, I’m having issues initializing the call.
I hope you can help me out. I need to get the balance of an address. Here my code:
Blockquote
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crypto wallet</title>
<script src="https://cdn.jsdelivr.net/gh/icon-project/icon-sdk-js@latest/build/icon-sdk-js.web.min.js"></script>
<script>
function getBalanceICX(){
const iconService = new IconService(new HttpProvider('https://bicon.net.solidwallet.io/api/v3'));
const myAddress = 'hx902ecb51c109183ace539f247b4ea1347fbf23b5';
const balance = await iconService.getBalance(myAddress).execute();
console.log(balance);
}
</script>
</head>
<body>
<script>
getBalanceICX();
</script>
</body>
</html>
Blockquote
If I add the async to the function I get errors 2. If I don’t I get errors 1 and 2.
- Uncaught SyntaxError: await is only valid in async function
index.html:19
- Uncaught ReferenceError: getBalanceICX is not defined.
Can you please assist? I feel super dumb asking this kind of assistance but thank you very much.
Regards.
Fabio.