How fix erorr 'Web3Api not initialized'

Hi guys, i have sample code

 const appId = "....";
        const serverUrl = "....";
       Moralis.initialize(appId);
       Moralis.serverURL = serverUrl;

      async function test() {
            let user = Moralis.User.current();
            var options = {
            'address' : user.get('ethAddress'),
            'chain' : '0x61'
            }
            balance = await Moralis.Web3API.account.getNativeBalance(options);
            console.log(balance)
        }

i had get a error ''Web3Api not initialized, run Moralis.start() first", but i change my code

 Moralis.initialize(appId);
 Moralis.serverURL = serverUrl;

with
Moralis.start({ serverUrl, appId });
it’s run, I don’t know why what is the difference between them? Moralis.initialize is deprecated? thank for help

Yes, Moralis.initialize is no longer used in new versions of Moralis SDK, starting with version 0.0.80 more exactly. It was a breaking change in Moralis SDK version 0.0.80 that started to use Moralis.start instead of Moralis.initialize.

ok thank, how to I can receive changlog from Moralis Team, I using src=β€œhttps://npmcdn.com/moral[email protected]/dist/moralis.js”, it will break my code if Moralis Team upgrade to new version, how to get stable version. Thanks

An example:

<script src="https://npmcdn.com/[email protected]/dist/moralis.js"></script>

1 Like

How to i can view list version of Moralis?

You can get current Moralis sdk version at runtime with Moralis.CoreManager.get("VERSION")

1 Like