Search.../

getCategoryBySlug( )

Developer Preview

Returns a single category by URL slug.

Admin Method

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

Syntax

function getCategoryBySlug(slug: string, options: GetCategoryBySlugOptions): Promise<CategoryResponse>

getCategoryBySlug Parameters

NAME
TYPE
DESCRIPTION
slug
string

URL slug.

options
Optional
GetCategoryBySlugOptions

Options specifying which fields to return.

Returns

Return Type:

Promise<
CategoryResponse
>
NAME
TYPE
DESCRIPTION
category
Category

Retrieved category for the provided category ID.

Was this helpful?

getCategoryBySlug example

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