Saturday, 14 May 2022

React js function not found in package

When using ElvWalletClient.Item({"x":"1","y":"2"}) from import { ElvWalletClient } from "@eluvio/elv-wallet-client";

I receive the following error

eluvio_elv_wallet_client__WEBPACK_IMPORTED_MODULE_1_.ElvWalletClient.Item is not a function

When looking into the source code I do see the method (line 338)

exports.Item = async function ({contractAddress, tokenId}) {
  Assert("Item", "Contract address", contractAddress);
  Assert("Item", "Token ID", tokenId);

  return await this.SendMessage({
    action: "item",
    params: {
      contractAddress,
      tokenId: tokenId.toString()
    }
  });
};

Code

import React, { useEffect, useState } from 'react'
import { ElvWalletClient } from "@eluvio/elv-wallet-client";

const Methods = ({client, userProfile}) => {
    const [itemData, setItemData] = useState(undefined);
    const popupClient = ElvWalletClient.Item({contractAddress: "0x48341be85e735322862d654a3f3c69854a16ccaf",itemId: "407"})
    .then(data => {
        itemData(data)

      })
      .catch(error => console.error(error));

    return (
        <div>
            <div>{itemData}</div>
        </div>
    )
}

export default Methods


from React js function not found in package

No comments:

Post a Comment