Closed
Description
i am trying to call the function below, in my react code to be able to get the token total supply and user token balance but i am getting the error Cannot read properties of undefined (reading 'then')
here is the error
here is the function :
export const getTotalTokenInformation = async (
hash: string,
address: string,
) => {
console.log("here");
const totalSupply = await coreSDK.getTotalHeartBitCountByHash({ hash });
console.log(totalSupply);
const mintsByUser = await coreSDK.getHeartBitByUser({
hash,
address,
});
return { totalSupply, balance: mintsByUser };
};
here is how i am trying to use it in my react code
function App() {
const tokenId =
"0x854e8c653cbe480b562a6919a936eff545c2accdea26d92f3de792bd8add927a";
const [tokenInfo, setTokenInfo] = useState<any>({});
const loadTokenInfo = async () => {
const res = await getTotalTokenInformation();
setTokenInfo(res);
};
useEffect(() => {
loadTokenInfo();
}, []);
return (
<div>
<h1>Total Supply: {tokenInfo?.totalSupply}</h1>
<h1>Total Supply: {tokenInfo?.balance}</h1>
<button onClick={() => mintToken(tokenId)}>MINT TOKEN</button>
</div>
);
}
```
export default App;`
Metadata
Metadata
Assignees
Labels
No labels