Search.../

getGroupBySlug( )

Gets a group by slug.

Description

The getGroupBySlug() function returns a Promise that resolves to a group whose slug matches the given slug. The slug is the end of a group's URL that refers to a specific group. For example, if a group's URL is https:/example.com/groups/{my-fitness-group}, the slug is my-fitness-group. The slug is case-sensitive. It is generally based on the group name, but for secret groups it is an autogenerated string of characters, for example, https:/example.com/groups/{5D3yTX}.

Note: For SECRET groups, only site admins, group admins, and group members can see a group and its content.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getGroupBySlug(slug: string): Promise<GetGroupBySlugResponse>

getGroupBySlug Parameters

NAME
TYPE
DESCRIPTION
slug
string

Unique part of the group's URL, for example group-1 in https:/example.com/groups/group-1. Pass only the slug. Case-sensitive.

Returns

Return Type:

Promise<
GetGroupBySlugResponse
>
NAME
TYPE
DESCRIPTION
group
Group

Retrieved group.

Was this helpful?

getGroupBySlug example

Copy Code
1import { groups } from 'wix-groups.v2';
2
3 async function getGroupBySlug(slug) {
4 try {
5 const result = await groups.getGroupBySlug(slug);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13