[SOLVED] Unable to unlink account from User

I ran the code below and get a 101 Object not found from the promise error. Trying to unlink an address from a user account. My account currently have 2 addresses linked, but want be able to remove the linked address.

await Moralis.Web3.unlink(walletAddress)

is that address still present in _EthAddress table?

Yes it is. Is also still in the user table under the accounts property

this is the code that should execute on that unlink:

It looks like the code is hitting where you mentioned. The query.get(accountsLower) promise is indeed throwing object not found error.

I am seeing this address in my database though:

what version of Moralis SDK are you using?

 "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@walletconnect/web3-provider": "^1.6.6",
    "api": "^3.4.2",
    "axios": "^0.24.0",
    "moralis": "^0.0.124",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "^7.20.2",
    "react-moralis": "^0.2.8",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },

are you authenticated with the user that has that eth address associated?

@cryptokid looks like I finally got it working for some reason having to call Moralis.User.current() before I call the unlink. If I didn’t do that, it was giving me that error.

const unlinkWallet = async(walletAddress) => {
    if (window.confirm(`Are you sure you want to unlink ${walletAddress} wallet?`)) {
        console.log(`unlink address: ${walletAddress}`);
        const currentUser = Moralis.User.current();
        console.log(`Is user still authenticated on unlink: ${currentUser.authenticated()}`);
        await Moralis.Web3.unlink(walletAddress).then((user) => {
          setWalletUser(user);
        }).catch((error) => {
          console.error(`${error.code}: ${error.message}`);
        });
    }
  }
1 Like