Search.../

getMemberCountsPerBadge( )

Developer Preview

Retrieves member count per badge.

Description

The getMemberCountsPerBadge function returns a Promise that resolves when the member counts of each badge are retrieved.

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

Syntax

function getMemberCountsPerBadge(): Promise<GetMemberCountsPerBadgeResponse>

getMemberCountsPerBadge Parameters

This function does not take any parameters.

Returns

Return Type:

Promise<
GetMemberCountsPerBadgeResponse
>
NAME
TYPE
DESCRIPTION
badgeMemberCounts
Array<
BadgeMemberCount
>

List of badges and counts of members who have each badge.

Was this helpful?

Get member count for badge.

Copy Code
1import { badges } from 'wix-members.v2';
2import { elevate } from 'wix-auth';
3
4export async function myGetMemberCountsPerBadgeFunction() {
5 try {
6 const elevatedMemberCountsPerBadge = elevate(badges.getMemberCountsPerBadge);
7 const badgeMemberCounts = await elevatedMemberCountsPerBadge()
8
9
10 console.log('Member count per badge: ', badgeMemberCounts);
11 return badgeMemberCounts;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16
17}
18
19/* Promise resolves to:
20 * {
21 * "badgeMemberCounts": [
22 * {
23 * "badgeId": "b657b857-774a-4dde-9b0e-f364d61092ea",
24 * "memberCount": 0
25 * },
26 * {
27 * "badgeId": "e80fed60-687e-4b91-a24c-252c4b32227b",
28 * "memberCount": 1
29 * },
30 * {
31 * "badgeId": "215be5d9-4b32-4861-9eb5-2152930dd0b4",
32 * "memberCount": 1
33 * }
34 * ]
35 * }
36 */
37