[SOLVED] Cannot read property 'encode' of undefined

Hello, i’m working with the js client and Playcanvas. The client is correctly created, i’m using the lastest nakama-js.umd.js and correctly imported into the engine.

// initialize code called once per entity
NetworkManager.prototype.initialize = function() {    
    var client = new nakamajs.Client("defaultkey", "[IP]", "[PORT]");
        
    var currentSession = null;
    
    client.ssl = false;
    print("print ho rha hai");
    
    var email = "super@heroes.com";
    var password = "batsignal";
    var session = client.authenticateEmail({ email: email, password: password });
    console.info(session);
};

    // update code called every frame
    NetworkManager.prototype.update = function(dt) {    
};

When i’m trying to connect to my server it throws an error:

Cannot read property 'encode' of undefined

SOLUTION: use this HOTFIX or download the 2.1.3 umd file.

hey @ameza this is a bug with our .umd.js distribution that we are moving away from. I am looking into it but in the meantime could you use our .esm distribution – I believe PlayCanvas supports ES modules.

Unfortunately, Playcanvas doesn’t support ES Modules, do you know if any older version can be used without that issue?

@ameza yes, 2.1.3 should work without a problem: Release v2.1.3 · heroiclabs/nakama-js · GitHub

I’m receiving a bad request response.

var client = new nakamajs.Client("defaultkey", "127.0.0.1", "7350");
        var currentSession = null;
        client.ssl = false;
        
        var email = "ameza@ggtech.es";
        var password = "batsignal";
        const username = "ameza"

        const session = client.authenticateEmail({ 
            email: email,
            password: password,
            username:username,
            create:true
        });
        console.log(session);

@ameza instead of passing the parameters as a single object, pass them individually like so:

client.authenticateEmail(email, password, create, username);
2 Likes

@ameza We’ve fixed the .umd.js bug in the latest release of the JS plugin:

1 Like