Skip to main content

CategoryService

Category service can be used in the following way:
1. Import the service from our library:

import {CategoryService} from "@selfcommunity/api-services";
2. Create a function and put the service inside it!
The async function `getAllCategories` will return the paginated list of categories.

async getAllCategories() {
return await CategoryService.getAllCategories();
}
In case of required `params`, just add them inside the brackets.

async getSpecificCategory(categoryId) {
return await CategoryService.getSpecificCategory(categoryId);
}
If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).

1. Declare it(or declare them, it is possible to add multiple params)

const headers = headers: {Authorization: `Bearer ${yourToken}`}

2. Add it inside the brackets and pass it to the function, as shown in the previous example!

Constructors

Constructor

new CategoryService(): CategoryService

Returns

CategoryService

Methods

checkCategoryIsFollowed()

static checkCategoryIsFollowed(id, config?): Promise<SCCategoryFollowedStatusType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig

Returns

Promise<SCCategoryFollowedStatusType>


createCategory()

static createCategory(data, config?): Promise<SCCategoryType>

Parameters

ParameterType
dataSCCategoryType
config?AxiosRequestConfig

Returns

Promise<SCCategoryType>


deleteASpecificCategory()

static deleteASpecificCategory(id, config?): Promise<any>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig

Returns

Promise<any>


followCategory()

static followCategory(id, config?): Promise<any>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig

Returns

Promise<any>


getAllCategories()

static getAllCategories(params?, config?): Promise<SCPaginatedResponse<SCCategoryType>>

Parameters

ParameterType
params?CategoryParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCCategoryType>>


getCategoryAudience()

static getCategoryAudience(id, config?): Promise<SCCategoryAudienceType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig

Returns

Promise<SCCategoryAudienceType>


getCategoryFeed()

static getCategoryFeed(id, params?, config?): Promise<SCPaginatedResponse<SCFeedUnitType>>

Parameters

ParameterType
idstring | number
params?BaseGetParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCFeedUnitType>>


getCategoryFollowers()

static getCategoryFollowers(id, params?, config?): Promise<SCPaginatedResponse<SCUserType>>

Parameters

ParameterType
idstring | number
params?BaseGetParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCUserType>>


getCategoryTrendingFeed()

static getCategoryTrendingFeed(id, params?, config?): Promise<SCPaginatedResponse<SCFeedUnitType>>

Parameters

ParameterType
idstring | number
params?BaseGetParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCFeedUnitType>>


getCategoryTrendingFollowers()

static getCategoryTrendingFollowers(id, params?, config?): Promise<SCPaginatedResponse<SCUserType>>

Parameters

ParameterType
idstring | number
params?BaseGetParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCUserType>>


getFollowedCategories()

static getFollowedCategories(params?, config?): Promise<SCPaginatedResponse<SCCategoryType>>

Parameters

ParameterType
params?CategoryParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCCategoryType>>


getPopularCategories()

static getPopularCategories(params?, config?): Promise<SCPaginatedResponse<SCCategoryType>>

Parameters

ParameterType
params?BaseGetParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCCategoryType>>


getSpecificCategory()

static getSpecificCategory(id, config?): Promise<SCCategoryType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig

Returns

Promise<SCCategoryType>


patchASpecificCategory()

static patchASpecificCategory(id, data, config?): Promise<SCCategoryType>

Parameters

ParameterType
idstring | number
dataSCCategoryType
config?AxiosRequestConfig

Returns

Promise<SCCategoryType>


searchCategory()

static searchCategory(params?, config?): Promise<SCPaginatedResponse<SCCategoryType>>

Parameters

ParameterType
params?CategoryParams
config?AxiosRequestConfig

Returns

Promise<SCPaginatedResponse<SCCategoryType>>


updateASpecificCategory()

static updateASpecificCategory(id, data, config?): Promise<SCCategoryType>

Parameters

ParameterType
idstring | number
dataSCCategoryType
config?AxiosRequestConfig

Returns

Promise<SCCategoryType>