2015-10-06 67 views
2

我試圖使用Syncano用戶管理系統實現用戶註冊我的應用程序。我可以使用下面的JS庫代碼成功地創建一個新用戶:Syncano用戶管理配置文件更新錯誤

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"}"

任何想法?

+0

看着這個。我沒有得到404,但我確實得到了一個不同的錯誤。我可能需要重做我的例子。 –

回答

1

看起來像示例代碼有問題(可悲的是我寫的)。

被用戶創建後返回的對象具有用於user對象的id字段,以及profile.id修改user_profile對象。

線必須是這個,而不是

instance.class('user_profile').dataobject(res.profile.id).update({firstName: 'First', lastName: 'Last'}); 

有一個在當前系統中另一個需要注意的,我也會讓一個音符 - 你必須先設置other permissionsreaduser_profile類。

這將最終在平臺中更改爲默認read

希望這會有所幫助!