Search.../

queryPosts( )

Developer Preview

Returns a list of posts by query.

Description

Paging

  • limit: default - 10, min - 0, max - 100
  • offset: default - 0, min - 0

Filterable fields:

  • id
  • categoryId
  • ownerId
  • title
  • contentText
  • bestAnswerCommentId
  • pinned
  • commentingEnabled
  • commentCount
  • likeCount
  • viewCount
  • createdDate
  • editedDate
  • lastActivityDate
  • slug

Sortable fields:

  • lastActivityDate
  • createdDate
  • commentCount
  • viewCount
  • likeCount
  • pinned
Admin Method

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

Syntax

function queryPosts(options: QueryPostsOptions): Promise<QueryPostsResponse>

queryPosts Parameters

NAME
TYPE
DESCRIPTION
options
Optional
QueryPostsOptions

Options for sorting, filtering, paging, and specifying return fields.

Returns

Return Type:

Promise<
QueryPostsResponse
>
NAME
TYPE
DESCRIPTION
metaData
QueryPostsResponseMetaData

Pagination.

posts
Array<
Post
>

List of posts.

Was this helpful?

queryPosts example

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