Search.../

listMembersByBadge( )

Lists the IDs of all members assigned to a badge.

Description

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

Retrieves up to 1000 site members who have a specified badge. Default paging.limit is 100, paging.offset - 0.

The _id parameter must be an ID from your site's Members/Badges collection. Typically, you retrieve the ID from the collection using a query or through a dataset.

This function is not a universal function and runs only on the backend.

Syntax

function listMembersByBadge(_id: string, options: ListMembersByBadgeOptions): Promise<ListMembersResponse>

listMembersByBadge Parameters

NAME
TYPE
DESCRIPTION
_id
string

Badge ID.

options
Optional
ListMembersByBadgeOptions

Returns

Return Type:

Promise<
ListMembersResponse
>
NAME
TYPE
DESCRIPTION
memberIds
Array<
string
>

Member IDs assigned to the badge.

metadata
PagingMetadata

Metadata for the paginated results.

Was this helpful?

List member IDs with assigned badges.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample _id value: 'ff8e00e5-babd-4fa5-810f-07e932a14d6e'
5 *
6 * Sample options value:
7 * {
8 * paging: {
9 * limit: 3,
10 * offset: 0
11 * }
12 * }
13 */
14
15export async function myListMembersByBadgeFunction(_id, options) {
16 try {
17 const elevatedListMembersByBadge = elevate(badges.listMembersByBadge);
18 const membersByBadge = await elevatedListMembersByBadge(_id, options);
19
20 console.log('Members by Badge: ', membersByBadge);
21 return membersByBadge;
22 } catch (error) {
23 console.error(error);
24 // Handle the error
25 }
26
27}
28
29/* Promise resolves to:
30 * {
31 * "memberIds": [
32 * "7d368843-6f0c-4037-8d0e-b7e36a8a0c32"
33 * ],
34 * "metadata": {
35 * "count": 1,
36 * "offset": 0,
37 * "total": 1
38 * }
39 * }
40 */