Search.../

listMembers( )

Lists the IDs of all members assigned to a badge.

Description

The listMembers() function returns a Promise that resolves to a list of member IDs assigned to the specified badge.

Note: This function replaces the deprecated wix-users-backend.badges.listMembers(). The deprecated function will continue to work, but it will not receive updates. To keep any existing code compatible with future changes, see the migration instructions.

Syntax

function listMembers(badgeId: string): Promise<Array<string>>

listMembers Parameters

NAME
TYPE
DESCRIPTION
badgeId
string

ID of the badge to list members of.

Returns

Fulfilled - IDs of the members assigned to the badge. Rejected - Error message.

Return Type:

Promise<Array<string>>

Was this helpful?

List members assigned to a badge

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { badges } from 'wix-members-backend';
3
4export const myListMembersFunction = webMethod(Permissions.Anyone, () => {
5 const badgeId = "571495e9-98af-4ec9-b854-16c0293c9312";
6
7 return badges.listMembers(badgeId)
8 .then((memberIds) => {
9 const firstMember = memberIds[0];
10 return memberIds;
11 })
12 .catch((error) => {
13 console.error(error);
14 });
15});
16
17/*
18 * Promise resolves to:
19 * [
20 * "28d35f86-6694-4455-9dff-aff5d450b482",
21 * "72751428-2743-4bda-acf5-4218a4279cd3",
22 * "8831eed6-928e-4f85-b80a-e1e48fb7c4fd"
23 * ]
24 */