listDraftPosts( )


Retrieves a list of up to 100 draft posts per request.

List Draft Posts runs with these defaults, which you can override:

  • editedDate is sorted in descending order.
  • paging.limit is 50.
  • paging.offset is 0.
Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function listDraftPosts(
  options: ListDraftPostsOptions,
): Promise<ListDraftPostsResponse>;
Method Parameters
optionsListDraftPostsOptions

Options for listing multiple draft posts.

Returns
Return Type:Promise<ListDraftPostsResponse>
JavaScript
import { draftPosts } from "wix-blog-backend"; import { webMethod, Permissions } from "wix-web-module"; import { elevate } from "wix-auth"; const elevatedListDraftPost = elevate(draftPosts.listDraftPosts); export const myListDraftPostFunction = webMethod( Permissions.Admin, async () => { try { const draftPosts = await elevatedListDraftPost(); console.log( "Successfully retrieved the following draft posts:", draftPosts, ); return draftPosts; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: * { * "draftPosts": [ * { * "_id": "57194b39-c4bc-45a6-a30d-f8e860a020b2", * "_createdDate": "2024-01-10T20:46:38.739Z", * "categoryIds": [], * "changeOrigin": "MANUAL_SAVE", * "commentingEnabled": true, * "contentId": "659f0938ca4ad1a823a0fe29", * "editingSessionId": "2e890d37-1a69-4153-9cc0-a36ea7e3d4ea", * "editedDate": "2024-01-10T21:16:53.964Z", * "featured": false, * "hashtags": [], * "hasUnpublishedChanges": true, * "language": "en", * "media": { * "custom": false, * "displayed": true, * "wixMedia": { * "image": "wix:image://v1/nsplsh_c9fb970af95242248fef3697783cd3db~mv2.jpg/Sunset%20on%20Monterosa.jpg#originWidth=3840&originHeight=5760" * } * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 7, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "settings": { * "keywords": [], * "preventAutoRedirect": false * }, * "tags": [] * }, * "slugs": [], * "status": "UNPUBLISHED", * "tagIds": [], * "title": "Mountain Ranger", * "translations": [] * }, * { * "_id": "d12f2ef2-c0f6-4913-b04f-aeeba2165b93", * "_createdDate": "2024-01-09T11:46:42.933Z", * "categoryIds": [], * "changeOrigin": "PUBLISH", * "commentingEnabled": true, * "contentId": "659d322302ee7b202a1745de", * "editingSessionId": "4e14aa41-ad7f-4e25-b4c4-df7144002aaf", * "editedDate": "2024-01-09T11:46:42.933Z", * "featured": true, * "firstPublishedDate": "2024-01-09T11:46:43.034Z", * "hashtags": [], * "hasUnpublishedChanges": false, * "language": "en", * "media": { * "custom": false, * "displayed": true * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 0, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "tags": [] * }, * "seoSlug": "rocket-man", * "slugs": [ * "rocket-man" * ], * "status": "PUBLISHED", * "tagIds": [], * "title": "Rocket Man", * "translations": [] * } * ], * "metaData": { * "count": 2, * "offset": 0, * "total": 17 * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?