listGroups( )


Lists groups.

The listGroups() function returns a Promise that resolves to a list of up to 1,000 groups on your site. Sorts by default to _createdDate in descending order.

Notes:

  • For SECRET groups, only site admins, group admins, and group members can see a list of group and their content. However, if the suppressAuth option is set to true, all permissions are overwritten, and all site members (including non-group members) can see a list of groups and their content.
  • This function's parameters are positional, and must be specified in the sequence shown in the syntax below. When specifying a parameter, use null as a placeholder for any unspecified parameters. For example, to specify limit only, call listGroups(paging, null). To specify supressAuth only, call listGroups(null, options).
Method Declaration
Copy
function listGroups(paging: Paging, options: Options): Promise<ListGroups>;
Method Parameters
pagingPaging

Paging options.


optionsOptions

Authorization options.

Returns
Return Type:Promise<ListGroups>
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { groups } from "wix-groups-backend"; export const myListGroupsFunction = webMethod(Permissions.Anyone, () => { return groups .listGroups() .then((groupResults) => { const groupResultsMemberCount = groupResults.groups[0].memberCount; const groupResultsName = groupResults.groups[0].name; return groupResults; }) .catch((error) => { console.error(error); }); }); /* Promise resolves to: * groups: [ * { * "_id": "83636377-b415-4ebe-ba41-df338c5ad6b7" * "name": "My Group 1" * "slug": "my-group-1" * "description": "Welcome to the group! You can connect with other members, get updates and share videos." * "privacyStatus": "PUBLIC" * "coverImage": { * "imageUrl": "wix:image://v1/vcc6074e348009011fa9f2d29kk7~mv2.jpg/maple.jpg#originWidth=999&originHeight=240", * "position": { * "x": 44, * "y": 90 * } * } * "memberCount": 83 * "settings": { * "groupUpdatePostEnabled": true * "membersCanApprove": false * "membersCanInvite": true * "showMemberList": true * "welcomeMemberPostEnabled": true * } * "lastActivityDate": "Sun Sep 26 2021 08:23:23 GMT+0300" * "_createdDate": "Tues January 22 2021 12:56:02 GMT+0300" * "_updatedDate": "Fri October 2 2021 04:56:22 GMT+0300" * "owner": "9ne8e9e1-d050-4c86-9684-e7f231600a34" * }, * { * "_id": "6ff5333-b477-4e9tt-ba4j-df338c5ad6221" * "name": "My Group 2" * "slug": "my-group-2" * "description": "Welcome to the group! You can connect with other members, get updates and share videos." * "privacyStatus": "PRIVATE" * "coverImage": { * "imageUrl": "wix:image://v1/dn33kcc6074e348009011fa9f2d29k03~mv2.jpg/fire.jpg#originWidth=287&originHeight=100", * "position": { * "x": 55, * "y": 166 * } * } * "memberTitle": "Friends" * "memberCount": 68 * "settings": { * "groupUpdatePostEnabled": true * "membersCanApprove": true * "membersCanInvite": true * "showMemberList": false * "welcomeMemberPostEnabled": true * } * "lastActivityDate": "Thurs Nov 12 2020 11:13:03 GMT+0300" * "_createdDate": "Wed May 14 2020 10:05:20 GMT+0300" * "_updatedDate": "Sun June 7 2020 09:07:33 GMT+0300" * "owner": "abe5e4e1-d950-4c46-8884-e7f231600d67" * } * ], * metadata: * { * "length": 2 * "tooManyToCount": false * "totalCount": 2 * } */
Errors

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

Did this help?