Cannot solve 'cannot read properties of undefined' error

Hello! I am using the boiler plate dex code from Moralis github, and whenever I try using the line ‘await Moralis.Plugins.oneInch.getSupportedTokens’. I have tried installing and uninstalling the 1Inch plugin from my server, both cause the same error. I will post part of my code (top of js file). Thank you so much!

const serverUrl = "https://XYZ;
const appId = "ABC";
Moralis.start({ serverUrl, appId });

async function init(){
    //await Moralis.initPulgins();
    await Moralis.enable();
    await listAvailableTokens();
}

async function listAvailableTokens(){
    const result = await Moralis.Plugins.oneInch.getSupportedTokens({
        chain: 'eth',
      });
    const tokens = result.tokens;
    let parent = document.getElementById("token_list");
    for( const address in tokens){
        let token = tokens[address];
        let div = document.createElement("div");
        div.className = "token_row";
        let html = `
        <img class="token_list_img" src="${token.logoURI}">
        <span class="token_list_text">${token.symbol}</span>
        `
        div.innerHTML = html;
        parent.appendChild(div);
    }
}

Hey @anna, before using any Moralis plugins, you need to initialize the plugin there with Moralis.initPlugins, seems like you comment that line out and have a bit of typo.

I also tried that, and I still get the error /:

can you post your error here so it can be easier to debug?

Here it as after I uncommented the line await.Moralis.initPlugins();

index.html:117 Live reload enabled.

main.js:7 Uncaught (in promise) TypeError: Moralis.initPulgins is not a function at init (main.js:7) at main.js:60

that error means your code is still typo, you should change initPulgins to initPlugins

1 Like

omg thank you so much LOL

1 Like

no problem, happy BUIDL~

1 Like