Search...
updateDraftPost( )
Updates a draft post.
Syntax
function updateDraftPost(_id: string, draftPost: UpdateDraftPost, options: UpdateDraftPostOptions): Promise<UpdateDraftPostResponse>
updateDraftPost Parameters
NAME
TYPE
DESCRIPTION
_id
string
Draft post ID.
draftPost
UpdateDraftPost
Draft Post info.
options
Optional
UpdateDraftPostOptions
Options for updating a draft post.
Returns
Return Type:
Promise<
UpdateDraftPostResponse
>NAME
TYPE
DESCRIPTION
draftPost
DraftPost
Updated draft post info.
Was this helpful?
Update a draft post (export from backend code)
Copy Code
1import { draftPosts } from 'wix-blog-backend';2import { webMethod, Permissions } from 'wix-web-module';34/* Sample id value: "c4696594-b02e-4d24-afc1-97da073783b4"5 *6 * Sample draftPost value:7 * {8 * "categoryIds": [],9 * "commentingEnabled": true,10 * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",11 * "excerpt": "When we start, we start from the beginning.",12 * "featured": false,13 * "hashtags": [],14 * "language": "en",15 * "media": {16 * "custom": false,17 * "displayed": true18 * },19 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",20 * "paidContentParagraph": 4,21 * "pricingPlanIds": [],22 * "relatedPostIds": [23 * "c4696594-b02e-4d24-afc1-97da073783b4",24 * "66935097-31c5-4fab-9693-aa1b53aeea77"25 * ],26 * "seoData": {27 * "tags": []28 * },29 * "tagIds": [],30 * "title": "How to make friends and influence people.",31 * "translations": []32 * }33 */3435export const myUpdateDraftPostFunction = webMethod(36 Permissions.Admin,37 async (id, draftPost) => {38 try {39 const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost);40 console.log('Successfully updated the following draft post":', updatedDraftPost);41 return updatedDraftPost;42 } catch (error) {43 console.error(error);44 // Handle the error45 }46 }47);4849/* Promise resolves to:50 * {51 * "categoryIds": [],52 * "commentingEnabled": true,53 * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",54 * "excerpt": "When we start, we start from the beginning.",55 * "featured": false,56 * "hashtags": [],57 * "language": "en",58 * "media": {59 * "custom": false,60 * "displayed": true61 * },62 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",63 * "paidContentParagraph": 4,64 * "pricingPlanIds": [],65 * "relatedPostIds": [66 * "c4696594-b02e-4d24-afc1-97da073783b4",67 * "66935097-31c5-4fab-9693-aa1b53aeea77"68 * ],69 * "seoData": {70 * "tags": []71 * },72 * "tagIds": [],73 * "title": "How to make friends and influence people.",74 * "translations": []75 * }76 */
Update a draft post using options (export from backend code)
Copy Code
1// This example updates the draft and publishes it2import { draftPosts } from 'wix-blog-backend';3import { webMethod, Permissions } from 'wix-web-module';45/* Sample id value = "c8d50953-b31c-435f-82ec-a53d8bff87b4"6 *7 * Sample draftPost value:8 * {9 * "categoryIds": [],10 * "commentingEnabled": true,11 * "excerpt": "If it wasn't for grit, we wouldn't succeed.",12 * "featured": false,13 * "hashtags": [14 * "vacation",15 * "dream",16 * "summer",17 * ],18 * "language": "en",19 * "media": {20 * "custom": false,21 * "displayed": true22 * },23 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",24 * "paidContentParagraph": 4,25 * "pricingPlanIds": [],26 * "relatedPostIds": [],27 * "seoData": {28 * tags": []29 * },30 * "tagIds": [],31 * "title": "Grit is the special sauce.",32 * "translations": []33 * };34 *35 * Sample options value":36 * {37 * "action": "UPDATE_PUBLISH",38 * "fieldsets": "GENERATED_EXCERPT",39 * "scheduledPublishDate": new Date("2024-08-09T15:30:00Z")40 * }41 */4243export const myUpdateDraftPostFunction = webMethod(44 Permissions.Admin,45 async (id, draftPost, options) => {46 try {47 const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost, options);48 console.log('Successfully updated the following draft post":', updatedDraftPost);49 return updatedDraftPost;50 } catch (error) {51 console.error(error);52 // Handle the error53 }54 }55);5657/* Promise resolves to:58 * {59 * "categoryIds": [],60 * "commentingEnabled": true,61 * "excerpt": "If it wasn't for grit, we wouldn't succeed.",62 * "featured": false,63 * "hashtags": [64 * "vacation",65 * "dream",66 * "summer"67 * ],68 * "language": "en",69 * "media": {70 * "custom": false,71 * "displayed": true72 * },73 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",74 * "paidContentParagraph": 4,75 * "pricingPlanIds": [],76 * "relatedPostIds": [],77 * "seoData": {78 * "tags": []79 * },80 * "tagIds": [],81 * "title": "Grit is the special sauce."82 * }83 */
Update a draft post
Copy Code
1import { draftPosts } from 'wix-blog-backend';23/* Sample id value: "c4696594-b02e-4d24-afc1-97da073783b4"4 *5 * Sample draftPost value:6 * {7 * categoryIds: [],8 * commentingEnabled: true,9 * editingSessionId: "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",10 * excerpt: "When we start, we start from the beginning.",11 * featured: false,12 * hashtags: [],13 * language: "en",14 * media: {15 * custom: false,16 * displayed: true17 * },18 * memberId: "c00e8a5c-322b-4e77-8813-002e3ea7e811",19 * paidContentParagraph: 4,20 * pricingPlanIds: [],21 * relatedPostIds: [22 * "c4696594-b02e-4d24-afc1-97da073783b4",23 * "66935097-31c5-4fab-9693-aa1b53aeea77"24 * ],25 * seoData: {26 * tags: []27 * },28 * tagIds: [],29 * title: "How to make friends and influence people.",30 * translations: []31 * }32 */3334export async function myUpdateDraftPostFunction(id, draftPost) {35 try {36 const updatedDraftPost = await draftPosts.updateDraftPost(id, draftPost);37 console.log('Successfully updated the following draft post:', updatedDraftPost);38 return updatedDraftPost;39 } catch (error) {40 console.error(error);41 // Handle the error42 }43 }44);4546/* Promise resolves to:47 * {48 * "categoryIds": [],49 * "commentingEnabled": true,50 * "editingSessionId": "5e9c24a9-6318-4ca7-9df5-0d9a6a10d3ee",51 * "excerpt": "When we start, we start from the beginning.",52 * "featured": false,53 * "hashtags": [],54 * "language": "en",55 * "media": {56 * "custom": false,57 * "displayed": true58 * },59 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",60 * "paidContentParagraph": 4,61 * "pricingPlanIds": [],62 * "relatedPostIds": [63 * "c4696594-b02e-4d24-afc1-97da073783b4",64 * "66935097-31c5-4fab-9693-aa1b53aeea77"65 * ],66 * "seoData": {67 * "tags": []68 * },69 * "tagIds": [],70 * "title": "How to make friends and influence people.",71 * "translations": []72 * }73 */