How to use getChainId in Angular

I’m trying to use getChainId in my Angular project and it seems to me like there is a problem with the Moralis import in Angular because I cannot use it like this.

import { Moralis } from 'moralis';

private _chainId = Moralis.getChainId();
console.log(chainId); // 56

I don’t understand what it doesn’t work, there also seems to be different names for those chainId variables.

Okay I just realized that I can’t use any of the methods introduced in this page
and I have no idea why. I changed my code to this:

const chainId = new Moralis.

and I looked at all of the recommendations but there’s just no getChainId anywhere.

usually to get the chainid you have first to use enableWeb3 to be connected to a wallet

but this may not be your current problem

1 Like