オーナーユーザーの取得
グループのオーナーは getOwner()
メソッドで取得できます。
返却される KiiUser
のインスンタンスは ID
のみを保持した不完全なインスタンスであることに注意してください。必要に応じて refresh()
メソッドを実行して Kii Cloud よりユーザーの最新情報を取得してください。
なお、取得するユーザーとログイン中のユーザーが異なる場合、取得できる情報に制限があります。詳細は ユーザー属性 を参照してください。
グループのオーナーを取得するサンプルコードを以下に示します。
-
// Get the owner user of members of the group. group.getOwner().then( function(params) { var group = params[0]; var owner = params[1]; // Refresh the owner to retrieve the latest data from Kii Cloud. return owner.refresh(); } ).then( function(owner) { // Do something. } ).catch( function(error) { // Handle the error. // Get the group for the failed getOwner() method. var thrGroup = error.target; // Get the user for the failed refresh() method. var theUser = error.target; // Get the error message. var errorString = error.message; } );
-
// Get the owner user of the group. group.getOwner({ success: function(theGroup, owner) { // Refresh the owner to retrieve the latest data from Kii Cloud. owner.refresh({ success: function(theUser) { // Do something. }, failure: function(theUser, errorString) { // Handle the error. } }); }, failure: function(theGroup, errorString) { // Handle the error. } });