Check if an address is a EOA or contract

I am trying to determine wether or not an address I pull from the request objects is a smart contract or an externally owned address. I came up with this function which seems to work but somehow it is not always correct.

Moralis.Cloud.define("isContract", async request => {
  if (!request.params.address) return;
  try {
    const result = await web3.eth.getCode(request.params.address);
    if (result !== "0x") {
      return true;
    }
    return false;
  } catch (error) {
    logger.info("Error: " + error);
  }
});

For example when I feed this function with the address 0x64a078926ad9f9e88016c199017aea196e3899e1

it returns this value

0x608060405234801561001057600080fd5b5060043610610โ€ฆ

which according to my function above should return โ€œtrueโ€ but it is saved in my database as false. Anyone sees where Im going wrong here?

the logic from this function seems ok to me

I agree on that. Confusing to me why I have values of โ€œfalseโ€ in my EthTokenTransfers table when from- or to_address returned โ€œtrueโ€ by this function.

Can you log inside if (result !== "0x") { for this particular address? Just to make sure itโ€™s executing that block as it should.