1、nakama-js 仓库地址下载,dist目录内容
https://github.com/heroiclabs/nakama-js
2、将dist 目录文件copy 到 cocos assets/libs/nakama下,没有自己新建一个目录
3、修改nakama-js.umd.js 重命名为 index.js
4、其他页面使用
import nakama from '../libs/nakama/index.js';
test(){
var serverkey = "defaultkey";
var host = "127.0.0.1";
var port = "7350";
var useSSL = false;
var timeout = 7000; // ms
const email = "hello@example.com";
const password = "somesupersecretpassword";
var client = new nakama.Client(serverkey, host, port, useSSL, timeout);
client.authenticateEmail(email,password).then(session => {
console.log("Session", session);
}).catch(error => {
console.log("Error----", error);
});
}