Updates a draft post.
function updateDraftPost(
_id: string,
draftPost: UpdateDraftPost,
options: UpdateDraftPostOptions,
): Promise<UpdateDraftPostResponse>;
Draft post ID.
Draft Post info.
Options for updating a draft post.
import { draftPosts } from "wix-blog-backend";
import { webMethod, Permissions } from "wix-web-module";
/* Sample id value: "c4696594-b02e-4d24-afc1-97da073783b4"
*
* Sample draftPost value:
* {
* "categoryIds": [],
* "commentingEnabled": true,
* "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",
* "excerpt": "When we start, we start from the beginning.",
* "featured": false,
* "hashtags": [],
* "language": "en",
* "media": {
* "custom": false,
* "displayed": true
* },
* "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
* "paidContentParagraph": 4,
* "pricingPlanIds": [],
* "relatedPostIds": [
* "c4696594-b02e-4d24-afc1-97da073783b4",
* "66935097-31c5-4fab-9693-aa1b53aeea77"
* ],
* "seoData": {
* "tags": []
* },
* "tagIds": [],
* "title": "How to make friends and influence people.",
* "translations": []
* }
*/
export const myUpdateDraftPostFunction = webMethod(
Permissions.Admin,
async (id, draftPost) => {
try {
const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost);
console.log(
'Successfully updated the following draft post":',
updatedDraftPost,
);
return updatedDraftPost;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
* {
* "categoryIds": [],
* "commentingEnabled": true,
* "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",
* "excerpt": "When we start, we start from the beginning.",
* "featured": false,
* "hashtags": [],
* "language": "en",
* "media": {
* "custom": false,
* "displayed": true
* },
* "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",
* "paidContentParagraph": 4,
* "pricingPlanIds": [],
* "relatedPostIds": [
* "c4696594-b02e-4d24-afc1-97da073783b4",
* "66935097-31c5-4fab-9693-aa1b53aeea77"
* ],
* "seoData": {
* "tags": []
* },
* "tagIds": [],
* "title": "How to make friends and influence people.",
* "translations": []
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.