0

I am using a secondary key to get table rows:

static async getItemById(itemId){
    try{
      const rpc = new JsonRpc(process.env.REACT_APP_EOS_HTTP_ENDPOINT);
      const result = await rpc.get_table_rows({
        "json": true,
        "code": process.env.REACT_APP_EOS_CONTRACT_NAME,
        "scope": process.env.REACT_APP_EOS_CONTRACT_NAME,
        "index_position": "secondary",
        "key_type": "uint64_t",
        "table": "items",
        "limit": 10,
        "lower_bound": itemId,
      });
      console.log(result.rows)
      return result.rows;
    } catch (err) {
        console.error(err);
    }
  }

but I get this error:

Error: Unsupported secondary index type: uint64_t
    at new RpcError (eosjs-rpcerror.js:27)
    at JsonRpc.<anonymous> (eosjs-jsonrpc.js:121)
    at step (eosjs-jsonrpc.js:37)
    at Object.next (eosjs-jsonrpc.js:18)
    at fulfilled (eosjs-jsonrpc.js:9)

1 Answer 1

0

It seems that I need to use i64 instead of uint64_t. The API reference is confusing. It clearly mentions uint64_t as an example for the key_type!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.