我已经在Google云平台上的VM上使用docker容器方法安装了Realm Object Server。容器正在运行,我可以在浏览器中连接并查看ROS页面。我可以使用Realm Studio连接到它并添加用户。
我有一个在Mac上本地运行的nodeJS应用程序,我正在尝试使用它来登录并写入服务器上的域。当我运行应用程序时,我收到一个错误,返回的用户是一个空对象。不知道我做错了什么。 我是NodeJS的新手。
代码:
var theRealm;
const serverUrl = "http://xx.xx.xx.xx:9080";
const username = "xxxx";
const password = "xxxx";
var token = "long-token-for-enterprise-trial";
Realm.Sync.setFeatureToken(token);
console.log("Will log in user");
Realm.Sync.User.login(serverUrl, username, password)
.then(user => {
``
// user is logged in
console.log("user is logged in " + util.inspect(user));
// do stuff ...
console.log("Will create config");
const config = {
schema:[
schema.interventionSchema,
schema.reportSchema
],
sync: {
user: user,
url: serverUrl
}
};
console.log("Will open realm with config: " + config);
const realm = Realm.open(config)
.then(realm => {
// use the realm instance here
console.log("Realm is active " + realm);
console.log("Will create Realm");
theRealm = new Realm({
path:'model/realm_db/theRealm.realm',
schema:[
schema.interventionSchema,
schema.reportSchema
]
});
console.log("Did create Realm: " + theRealm);
})
.catch(error => {
// Handle the error here if something went wrong
console.log("Error when opening Realm: " + error);
});
})
.catch(error => {
// an auth error has occurred
console.log("Error when logging in user: " + error);
});
输出:
Will log in user
Server is running...
user is logged in {}
Will create config
Will open realm with config: [object Object]
TypeError: Cannot read property 'token_data' of undefined
at performFetch.then.then (/pathToProject/node_modules/realm/lib/user-methods.js:203:49)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: Cannot read property 'token_data' of undefined
at performFetch.then.then (/pathToProject/node_modules/realm/lib/user-methods.js:203:49)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
错误@ user-methods.js:203:49
const tokenData = json.access_token.token_data;
json是: {user_token: {token:'xxxxxxxx', token_data: {app_id:'io.realm.Auth', 身份:'xxxxxxx', 盐:'xxxxxxxx', 到期日期:1522930743, is_admin:false}}};
所以json.access_token.token_data是未定义但是json。 user_token.token_data不会。
答案 0 :(得分:0)
我建议你尝试与realm studio的ROS连接,因为你可以检查日志,这将帮助你修复错误。如果你仍然无法修复那么你可以联系Realm支持团队,即使他们帮助我使用Docker解决Xamarin Forms中的ROS连接问题。