error "Uncaught TypeError: Cannot read property 'getPlayer' of undefined"

Why is this error happening?

<script type="text/javascript">
  var player;
  var sdk;
  var ysdk;

    YaGames.init().then(ysdk => {
    console.log('Yandex SDK initialized');
    window.ysdk = ysdk;
    });

    ysdk.getPlayer()

    player.setData({
        Save: ['G.Egs'],
    }).then(() => {
        console.log('data is set');
    });

</script>

I’m a beginner and don’t really understand why it doesn’t work
documentation
Unfortunately it is in Russian, but I hope you can explain what I’m doing wrong

This is javascript, I’m not sure what this has to do with Unity? This is a Unity scripting part of the forum, which is c#. Since your code mentions Yandex SDK, you probably need to ask on their forum.

2 Likes

You probably want this GitHub - yandexmobile/yandex-ads-unity-plugin: Yandex Mobile Ads Unity Plugin and Adding the Mobile Ads Unity plugin. Integration