listMembersByBadge( )


Lists the IDs of all members assigned to a badge.

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.

Permissions
Manage Badges
Read Badges
Learn more about app permissions.
Method Declaration
Copy
function listMembersByBadge(
  _id: string,
  options: ListMembersByBadgeOptions,
): Promise<ListMembersResponse>;
Method Parameters
_idstringRequired

Badge ID.


optionsListMembersByBadgeOptions
Returns
Return Type:Promise<ListMembersResponse>
JavaScript
import { badges } from "wix-members.v2"; import { elevate } from "wix-auth"; /* Sample _id value: 'ff8e00e5-babd-4fa5-810f-07e932a14d6e' * * Sample options value: * { * paging: { * limit: 3, * offset: 0 * } * } */ export async function myListMembersByBadgeFunction(_id, options) { try { const elevatedListMembersByBadge = elevate(badges.listMembersByBadge); const membersByBadge = await elevatedListMembersByBadge(_id, options); console.log("Members by Badge: ", membersByBadge); return membersByBadge; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "memberIds": [ * "7d368843-6f0c-4037-8d0e-b7e36a8a0c32" * ], * "metadata": { * "count": 1, * "offset": 0, * "total": 1 * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?