跳到主要内容

Get Groups

List and look up RainMaker node groups for the signed-in user.

备注

Obtain userInstance via ESPRMAuth.getLoggedInUser() after sign-in.

const authInstance = ESPRMBase.getAuthInstance();
const userInstance = await authInstance.getLoggedInUser();

What This Module Does ?

Retrieve groups the user owns or can access—paginated lists, lookup by ID, or lookup by name.

Use this when building a group picker, home/room list, or before group-level operations on a specific ESPRMGroup.

Use Manage Groups to create or mutate groups.

Expected outcome: ESPRMGroup instances (or lists) you can render or pass to share/metadata APIs.

Common Workflows

List all groups (paginated)

let allGroups = [];
let response = await userInstance.getGroups({
resultCount: 10,
withNodeList: true,
withSubGroups: true,
});

allGroups = allGroups.concat(response.groups);

while (response.hasNext) {
response = await response.fetchNext();
allGroups = allGroups.concat(response.groups);
}

Get group by ID

const group = await userInstance.getGroupById({
groupId: "group_id_123",
});

Get group by name

const group = await userInstance.getGroupByName({
groupName: "Living Room Devices",
});

Error Handling

try {
const group = await userInstance.getGroupById({ groupId });
if (!group) console.warn("Group not found");
} catch (error) {
console.error("Failed to load group:", error);
}

Best Practices

  1. Request withNodeList when the UI shows device counts per group
  2. Paginate for accounts with many groups
  3. Cache group instances briefly to avoid repeated lookups during navigation

On this page