我尝试使用 Syncano 用户管理系统实现用户注册我的应用程序。我能够使用以下 JS 库代码成功创建新用户:
var sync = new Syncano({ apiKey: 'API_KEY', instance: 'INSTANCE' });
sync.user().add(signUp).then(function(res){
console.log(res);
}).catch(function(err) {
console.log(err);
});
然后我尝试按照此处找到的代码向我的用户添加配置文件字段:https://www.syncano.io/user-management-for-your-apps/#adding-fields
var sync = new Syncano({ apiKey: 'API_KEY', instance: 'INSTANCE' });
sync.user().add(signUp).then(function(res){
var instance = new Syncano({
apiKey: API_KEY,
instance: INSTANCE_NAME,
userKey: res.user_key
});
instance.class('user_profile').dataobject(res.id).update({firstName: 'First', lastName: 'Last'});
}).catch(function(err) {
console.log(err);
});
当我在第一个的 .then() 语句中进行第二个 API 调用时,出现此错误:
"api.syncano.io/v1/instances/INSTANCE/classes/user_profile/objects/26/:1 PATCH https://api.syncano.io/v1/instances/INSTANCE/classes/user_profile/objects/26/ 404 (NOT FOUND) user.service.js:77 Error: {"detail":"Not found"}"
有什么想法吗?
最佳答案
看起来示例代码有问题(我写的很遗憾)。
创建用户后返回的对象有一个 id
user
字段对象,和一个 profile.id
修改 user_profile
对象。
这条线需要改成这样
instance.class('user_profile').dataobject(res.profile.id).update({firstName: 'First', lastName: 'Last'});
当前系统中还有一个警告我也会记下 - 您必须首先设置 other permissions
至 read
在 user_profile
上类。
这最终将在平台中更改为默认为 read
.
希望这对您有所帮助!
关于javascript - Syncano 用户管理配置文件更新错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32980137/