I am trying to get user tokens with the following method:
static async getUserTokens(userAccount) {
console.log("Get tokens for: " + userAccount);
try {
const rpc = new JsonRpc("http://127.0.0.1:8888", { fetch });
const resp = await rpc.get_currency_balance({
code: "electro.coin",
account: "bob",
symbol: "EL"
});
//console.log(resp.rows[0]);
return resp.rows[0];
} catch (err) {
console.error(err);
}
}
and it returns:
eosjs-jsonrpc.js:99 POST http://127.0.0.1:8888/v1/chain/get_currency_balance 500 (Internal Server Error)
Error: Invalid cast from type 'object_type' to string
at new RpcError (eosjs-rpcerror.js:23)
at JsonRpc.eval (eosjs-jsonrpc.js:118)
at step (eosjs-jsonrpc.js:36)
at Object.eval [as next] (eosjs-jsonrpc.js:17)
at fulfilled (eosjs-jsonrpc.js:8)
Any explanation what am I missing? The token contract is electro.coin, the user is bob and the symbol is EL. I hard-coded the elements for better debugging, but no luck so far...
JSON.stringify(data)
const resp = await rpc.get_currency_balance("electro.coin", userAccount, "EL");
and it works :)