Search.../

listBadgesPerMember( )

Lists the badges assigned to each of the specified site members.

Description

The listBadgesPerMember() function returns a Promise that resolves to a list of badge IDs associated with each of the specified members.

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

Syntax

function listBadgesPerMember(memberIds: Array<string>): Promise<ListMembersBadgeIdsResponse>

listBadgesPerMember Parameters

NAME
TYPE
DESCRIPTION
memberIds
Array<
string
>

List of members.

Returns

Return Type:

Promise<
ListMembersBadgeIdsResponse
>
NAME
TYPE
DESCRIPTION
memberBadgeIds
Array<
MemberBadgeIds
>

List of members and the badges they're assigned to.

Was this helpful?

List badges assigned to specified members.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample memberIds value:
5 * [
6 * '7d368843-6f0c-4037-8d0e-b7e36a8a0c32'
7 * ]
8 */
9
10export async function myListBadgesPerMemberFunction(memberIds) {
11 try {
12 const elevatedListBadgesPerMember = elevate(badges.listBadgesPerMember);
13 const memberBadgeIds = await elevatedListBadgesPerMember(memberIds);
14
15 console.log('Member with assigned badges: ', memberBadgeIds);
16 return memberBadgeIds;
17 } catch (error) {
18 console.error(error);
19 // Handle the error
20 }
21
22}
23
24/* Promise resolves to:
25 * {
26 * "memberBadgeIds": [
27 * {
28 * "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
29 * "badgeIds": [
30 * "e80fed60-687e-4b91-a24c-252c4b32227b",
31 * "215be5d9-4b32-4861-9eb5-2152930dd0b4"
32 * ]
33 * }
34 * ]
35 * }
36 */