getDeletedDraftPost( )


Gets a deleted draft post from the trash bin by the provided ID.

Uses the provided draftPostId to retrieve a previously deleted draft post from the trash bin.

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 getDeletedDraftPost(
  draftPostId: string,
): Promise<GetDeletedDraftPostResponse>;
Method Parameters
draftPostIdstringRequired

Draft post ID.

Returns
Return Type:Promise<GetDeletedDraftPostResponse>
JavaScript
import { draftPosts } from "wix-blog-backend"; import { webMethod, Permissions } from "wix-web-module"; import { elevate } from "wix-auth"; // Sample draftPostId value: "26a7c0e49-036b-4874-b4cd-e015a22e857c" const elevatedGetDeletedDraftPost = elevate(draftPosts.getDeleteDraftPost); export const myGetDeletedDraftPostFunction = webMethod( Permissions.Admin, async (draftPostId) => { try { const deletedDraftPost = await elevatedGetDeletedDraftPost(draftPostId); console.log( "Successfully deleted the following draft post:", deletedDraftPost, ); return deletedDraftPost; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: * { * "draftPost": { * "_id": "6a7c0e49-036b-4874-b4cd-e015a22e857c", * "_createdDate": "2023-08-13T13:51:23.823Z", * "categoryIds": [ * "c8780752-f517-4cf9-9c18-0f9a22d00926", * "590635d7-cc7c-48cb-970c-f8339daa1cfe" * ], * "changeOrigin": "MOVE_TO_TRASH", * "commentingEnabled": true, * "contentId": "65a642ad69a6e0d73c4ae0b6", * "editedDate": "2024-01-16T08:47:56.900Z", * "featured": false, * "firstPublishedDate": "2023-03-22T14:16:01.202Z", * "hashtags": [ * "vacation", * "dream", * "summer", * "hashtag" * ], * "hasUnpublishedChanges": true, * "language": "en", * "media": { * "custom": false, * "displayed": true, * "wixMedia": { * "image": "wix:image://v1/a27d24_77c3bdd084c14f50a13aa9b44485c2e3~mv2.jpg/a27d24_11a0749276464a5faf356d2a8e73b842~mv2.jpg#originWidth=1868&originHeight=2612" * } * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 2, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "settings": { * "keywords": [], * "preventAutoRedirect": false * }, * "tags": [] * }, * "seoSlug": "how-decluttering-changed-my-life", * "slugs": [], * "status": "DELETED", * "tagIds": [ * "a55b2c06-cbec-4d01-a8bb-cd7029056c75", * "d2b0c02b-72c1-45af-ba58-3520cec9abe3" * ], * "title": "How decluttering changed my life", * "translations": [] * } * } */
Errors

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

Did this help?