Search...
getDeletedDraftPost( )
Gets a deleted draft post from the trash bin by the provided ID.
Description
Uses the provided draftPostId
to retrieve a previously deleted draft post from the trash bin.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Authorization
Request
This endpoint does not take any parameters
Response Object
NAME
TYPE
DESCRIPTION
draftPost
DraftPost
Draft post info.
Status/Error Codes
Was this helpful?
Get a deleted draft post from the trash bin (export from backend code)
Copy Code
1import { draftPosts } from 'wix-blog-backend';2import { webMethod, Permissions } from 'wix-web-module';3import { elevate } from 'wix-auth';45// Sample draftPostId value: "26a7c0e49-036b-4874-b4cd-e015a22e857c"67const elevatedGetDeletedDraftPost = elevate(draftPosts.getDeleteDraftPost);89export const myGetDeletedDraftPostFunction = webMethod(10 Permissions.Admin,11 async (draftPostId) => {12 try {13 const deletedDraftPost = await elevatedGetDeletedDraftPost(draftPostId);14 console.log('Successfully deleted the following draft post:', deletedDraftPost);15 return deletedDraftPost;16 } catch (error) {17 console.error(error);18 // Handle the error19 }20 }21);2223/* Promise resolves to:24 * {25 * "draftPost": {26 * "_id": "6a7c0e49-036b-4874-b4cd-e015a22e857c",27 * "_createdDate": "2023-08-13T13:51:23.823Z",28 * "categoryIds": [29 * "c8780752-f517-4cf9-9c18-0f9a22d00926",30 * "590635d7-cc7c-48cb-970c-f8339daa1cfe"31 * ],32 * "changeOrigin": "MOVE_TO_TRASH",33 * "commentingEnabled": true,34 * "contentId": "65a642ad69a6e0d73c4ae0b6",35 * "editedDate": "2024-01-16T08:47:56.900Z",36 * "featured": false,37 * "firstPublishedDate": "2023-03-22T14:16:01.202Z",38 * "hashtags": [39 * "vacation",40 * "dream",41 * "summer",42 * "hashtag"43 * ],44 * "hasUnpublishedChanges": true,45 * "language": "en",46 * "media": {47 * "custom": false,48 * "displayed": true,49 * "wixMedia": {50 * "image": "wix:image://v1/a27d24_77c3bdd084c14f50a13aa9b44485c2e3~mv2.jpg/a27d24_11a0749276464a5faf356d2a8e73b842~mv2.jpg#originWidth=1868&originHeight=2612"51 * }52 * },53 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",54 * "minutesToRead": 2,55 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",56 * "pricingPlanIds": [],57 * "relatedPostIds": [],58 * "seoData": {59 * "settings": {60 * "keywords": [],61 * "preventAutoRedirect": false62 * },63 * "tags": []64 * },65 * "seoSlug": "how-decluttering-changed-my-life",66 * "slugs": [],67 * "status": "DELETED",68 * "tagIds": [69 * "a55b2c06-cbec-4d01-a8bb-cd7029056c75",70 * "d2b0c02b-72c1-45af-ba58-3520cec9abe3"71 * ],72 * "title": "How decluttering changed my life",73 * "translations": []74 * }75 * }76 */
Get a deleted draft post from the trash bin (dashboard page code)
Copy Code
1import { draftPosts } from 'wix-blog-backend';23// Sample draftPostId value: "26a7c0e49-036b-4874-b4cd-e015a22e857c"45export async function myGetDeletedDraftPostFunction(draftPostId) {6 try {7 const deletedDraftPost = await draftPosts.getDeleteDraftPost(draftPostId);8 console.log('Successfully deleted the following draft post:', deletedDraftPost);9 return deletedDraftPost;10 } catch (error) {11 console.error(error);12 // Handle the error13 }14 }1516/* Promise resolves to:17 * {18 * "draftPost": {19 * "_id": "6a7c0e49-036b-4874-b4cd-e015a22e857c",20 * "_createdDate": "2023-08-13T13:51:23.823Z",21 * "categoryIds": [22 * "c8780752-f517-4cf9-9c18-0f9a22d00926",23 * "590635d7-cc7c-48cb-970c-f8339daa1cfe"24 * ],25 * "changeOrigin": "MOVE_TO_TRASH",26 * "commentingEnabled": true,27 * "contentId": "65a642ad69a6e0d73c4ae0b6",28 * "editedDate": "2024-01-16T08:47:56.900Z",29 * "featured": false,30 * "firstPublishedDate": "2023-03-22T14:16:01.202Z",31 * "hashtags": [32 * "vacation",33 * "dream",34 * "summer",35 * "hashtag"36 * ],37 * "hasUnpublishedChanges": true,38 * "language": "en",39 * "media": {40 * "custom": false,41 * "displayed": true,42 * "wixMedia": {43 * "image": "wix:image://v1/a27d24_77c3bdd084c14f50a13aa9b44485c2e3~mv2.jpg/a27d24_11a0749276464a5faf356d2a8e73b842~mv2.jpg#originWidth=1868&originHeight=2612"44 * }45 * },46 * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",47 * "minutesToRead": 2,48 * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811",49 * "pricingPlanIds": [],50 * "relatedPostIds": [],51 * "seoData": {52 * "settings": {53 * "keywords": [],54 * "preventAutoRedirect": false55 * },56 * "tags": []57 * },58 * "seoSlug": "how-decluttering-changed-my-life",59 * "slugs": [],60 * "status": "DELETED",61 * "tagIds": [62 * "a55b2c06-cbec-4d01-a8bb-cd7029056c75",63 * "d2b0c02b-72c1-45af-ba58-3520cec9abe3"64 * ],65 * "title": "How decluttering changed my life",66 * "translations": []67 * }68 * }69 */