CommentService
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
Constructor
new CommentService():
CommentService
Returns
CommentService
Methods
createComment()
staticcreateComment(data,config?):Promise<SCCommentType>
Parameters
| Parameter | Type | 
|---|---|
| data | CommentCreateParams | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCCommentType>
deleteComment()
staticdeleteComment(id,config?):Promise<any>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<any>
flagComment()
staticflagComment(id,flagType,config?):Promise<any>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| flagType | SCFlagTypeEnum | 
| config? | AxiosRequestConfig | 
Returns
Promise<any>
getAllComments()
staticgetAllComments(params,config?):Promise<SCPaginatedResponse<SCCommentType>>
Parameters
| Parameter | Type | 
|---|---|
| params | CommentListParams | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCPaginatedResponse<SCCommentType>>
getASpecificComment()
staticgetASpecificComment(id,config?):Promise<SCCommentType>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCCommentType>
getSpecificCommentFlags()
staticgetSpecificCommentFlags(id,config?):Promise<SCPaginatedResponse<SCFlagType>>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCPaginatedResponse<SCFlagType>>
getSpecificCommentFlagStatus()
staticgetSpecificCommentFlagStatus(id,config?):Promise<SCFlagType>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCFlagType>
getSpecificCommentVotesList()
staticgetSpecificCommentVotesList(id,config?):Promise<SCPaginatedResponse<SCVoteType>>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCPaginatedResponse<SCVoteType>>
restoreComment()
staticrestoreComment(id,config?):Promise<any>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<any>
updateComment()
staticupdateComment(id,text,config?):Promise<SCCommentType>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| text | string | 
| config? | AxiosRequestConfig | 
Returns
Promise<SCCommentType>
upvoteComment()
staticupvoteComment(id,config?):Promise<any>
Parameters
| Parameter | Type | 
|---|---|
| id | string|number | 
| config? | AxiosRequestConfig | 
Returns
Promise<any>