Skip to main content

CommentService

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

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

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

async getASpecificComment(commentId) {
return await CommentService.getASpecificComment(commentId);
}
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

new CommentService()

new CommentService(): CommentService

Returns

CommentService

Methods

createComment()

static createComment(data, config?): Promise<SCCommentType>

Parameters

ParameterType
dataCommentCreateParams
config?AxiosRequestConfig<any>

Returns

Promise<SCCommentType>

Source

services/comment/index.ts:170


deleteComment()

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

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<any>

Source

services/comment/index.ts:179


flagComment()

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

Parameters

ParameterType
idstring | number
flagTypeSCFlagTypeEnum
config?AxiosRequestConfig<any>

Returns

Promise<any>

Source

services/comment/index.ts:194


getASpecificComment()

static getASpecificComment(id, config?): Promise<SCCommentType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<SCCommentType>

Source

services/comment/index.ts:173


getAllComments()

static getAllComments(params, config?): Promise <SCPaginatedResponse<SCCommentType>>

Parameters

ParameterType
paramsCommentListParams
config?AxiosRequestConfig<any>

Returns

Promise <SCPaginatedResponse<SCCommentType>>

Source

services/comment/index.ts:167


getSpecificCommentFlagStatus()

static getSpecificCommentFlagStatus(id, config?): Promise<SCFlagType>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<SCFlagType>

Source

services/comment/index.ts:197


getSpecificCommentFlags()

static getSpecificCommentFlags(id, config?): Promise <SCPaginatedResponse<SCFlagType>>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise <SCPaginatedResponse<SCFlagType>>

Source

services/comment/index.ts:191


getSpecificCommentVotesList()

static getSpecificCommentVotesList(id, config?): Promise <SCPaginatedResponse<SCVoteType>>

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise <SCPaginatedResponse<SCVoteType>>

Source

services/comment/index.ts:185


restoreComment()

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

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<any>

Source

services/comment/index.ts:182


updateComment()

static updateComment(id, text, config?): Promise<SCCommentType>

Parameters

ParameterType
idstring | number
textstring
config?AxiosRequestConfig<any>

Returns

Promise<SCCommentType>

Source

services/comment/index.ts:176


upvoteComment()

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

Parameters

ParameterType
idstring | number
config?AxiosRequestConfig<any>

Returns

Promise<any>

Source

services/comment/index.ts:188