Search.../

getDraftPost( )

Developer Preview

Gets a draft post by the provided ID.

Description

Uses the provided draftPostId to retrieve a draft post.

Admin Method

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

Syntax

function getDraftPost(draftPostId: string, options: GetDraftPostOptions): Promise<DraftPost>

getDraftPost Parameters

NAME
TYPE
DESCRIPTION
draftPostId
string

Draft post ID.

options
Optional
GetDraftPostOptions

Options for getting a draft post.

Returns

Draft post info.

Return Type:

Promise<
DraftPost
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date the draft post was first created.

_id
string

Draft post ID.

categoryIds
Array<
string
>

Category IDs of the draft post.

changeOrigin
string

Reserved for internal use.

commentingEnabled
boolean

Whether commenting on the draft post is enabled.

content
Object

Reserved for internal use.

contentId
string

Reserved for internal use.

editedDate
Date

Date the draft post was last edited.

editingSessionId
string

Reserved for internal use.

excerpt
string

Draft post excerpt.

If no excerpt has been manually set, an excerpt is automatically generated from the post's text. This can be retrieved using the GENERATED_EXCERPT fieldset.

featured
boolean

Whether the draft post is marked as featured.

firstPublishedDate
Date

Date the post was first published.

hasUnpublishedChanges
boolean

Indicates if there are changes made to the draft post that have not yet been published.

hashtags
Array<
string
>

Hashtags in the draft post.

heroImage
string

Image placed at the top of the blog page.

internalId
string

Reserved for internal use.

language
string

Language the draft post is written in.

2-letter language code in ISO 639-1 alpha-2 format.

media
Media

Post cover media.

memberId
string

Draft post owner's member ID.

minutesToRead
number

Estimated reading time of the draft post (calculated automatically).

moderationDetails
ModerationDetails

Details of the draft post in review. Only relevant to posts submitted by guest writers.

mostRecentContributorId
string

Reserved for internal use.

previewTextParagraph
number

Number of paragraphs to display in a paid content preview for non-paying users.

pricingPlanIds
Array<
string
>

Pricing plan IDs. Only relevant if a post is assigned to a specific pricing plan.

relatedPostIds
Array<
string
>

IDs of posts related to this draft post.

richContent
RichContent

Draft post rich content.

scheduledPublishDate
Date

Date the draft post is scheduled to be published.

seoData
SeoSchema

SEO data.

seoSlug
string

SEO slug.

slugs
Array<
string
>

Reserved for internal use.

status
string

Status of the draft post.

tagIds
Array<
string
>

Tag IDs the draft post is tagged with.

title
string

Draft post title.

translationId
string

ID of the draft post's translations.

All translations of a single post share the same translationId. Available only if the Multilingual app is installed.

url
string

Draft post URL preview. What the URL will look like once the post is published.

Was this helpful?

getDraftPost example

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