'com.google.gwt.core.client.JavaScriptException: (TypeError) when I call method from constant in JS file from GWT

I have a file with this JS

const sdk = new ChartsEmbedSDK({
    baseUrl: 'https://mongodb.com....',
});

const chart = sdk.createChart({chartId: '1111111111111111111111111111'});

function loadDashboard() {
    chart.render(document.getElementById('chart'));
}

And call that from GWT code:

public static native void loadDashboard() /*-{
        $wnd.loadDashboard();
    }-*/;

It works. But when I do next In JS:

const sdk = new ChartsEmbedSDK({
    baseUrl: 'https://mongodb.com....',
});

const chart = sdk.createChart({chartId: '1111111111111111111111111111'}); 

and call:

public static native void loadDashboard() /*-{
    $wnd.chart.render($doc.getElementById('chart'));
}-*/;

I get error:

Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) : ((intermediate value)(intermediate value) , $wnd).chart.render is not a function


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source