> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: getDraftPost(draftPostId: string, options: GetDraftPostOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> draftPosts --> getDraftPost # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/draft-posts/get-draft-post.md # Method Description: Gets a draft post by the provided ID. Uses the provided `draftPostId` to retrieve a draft post. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get a draft post (export from backend code) ```javascript import { draftPosts } from 'wix-blog-backend'; import { webMethod, Permissions } from 'wix-web-module'; import { elevate } from 'wix-auth'; // Sample draftPostId value: "d655251a-74eb-467d-9beb-1962984b8d94" const elevatedGetDraftPost = elevate(draftPosts.getDraftPost); export const myGetDraftPostFunction = webMethod( Permissions.Admin, async (draftPostId) => { try { const draftPost = await elevatedGetDraftPost(draftPostId); console.log('Successfully retrieved the following draft post:', draftPost); return draftPost; } catch (error) { console.error(error); // Handle the error } } ); /* Promise resolves to: * { * "_id": "d655251a-74eb-467d-9beb-1962984b8d94", * "_createdDate": "2023-12-20T16:45:50.910Z", * "categoryIds": [ * "c8780752-f517-4cf9-9c18-0f9a22d00926", * "590635d7-cc7c-48cb-970c-f8339daa1cfe", * "2b2ccb5a-e709-45a1-8353-bb3332b91297", * "f2975644-ebb7-475f-baf5-5eb2b195880b" * ], * "changeOrigin": "MANUAL_SAVE", * "commentingEnabled": true, * "contentId": "65a639b469a6e0d73c4adfa6", * "editedDate": "2024-01-16T08:09:50.581Z", * "editingSessionId": "c8ce3dff-5005-4d40-badf-ceece77bc658", * "featured": false, * "hashtags": [], * "hasUnpublishedChanges": true, * "language": "en", * "media": { * "custom": false, * "displayed": true, * "wixMedia": { * "image": "wix:image://v1/wixsite_524366693776674a6a5559~mv2_d_6000_4000_s_4_2.jpg/orange%20tabby%20kitten%20in%20grasses.jpg#originWidth=6000&originHeight=4000" * } * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 2, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "settings": { * "keywords": [], * "preventAutoRedirect": false * }, * "tags": [] * }, * "seoSlug": "living-from-redemption", * "slugs": [], * "status": "UNPUBLISHED", * "tagIds": [ * "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67", * "a55b2c06-cbec-4d01-a8bb-cd7029056c75", * "d2b0c02b-72c1-45af-ba58-3520cec9abe3" * ], * "title": "The task at hand is worth it!", * "translations": [] * } */ ``` ## Get a draft post using options (export from backend code) ```javascript import { draftPosts } from 'wix-blog-backend'; import { webMethod, Permissions } from 'wix-web-module'; import { elevate } from 'wix-auth'; /* * Sample draftPostId value: "57194b39-c4bc-45a6-a30d-f8e860a020b2" * * Sample options value: * { * fieldsets: ["GENERATED_EXCERPT"] * } */ const elevatedGetDraftPost = elevate(draftPosts.getDraftPost); export const myGetDraftPostFunction = webMethod( Permissions.Admin, async (draftPostId, options) => { try { const draftPost = await elevatedGetDraftPost(draftPostId, options); console.log('Successfully retrieved the following draft post:', draftPost); return draftPost; } catch (error) { console.error(error); // Handle the error } } ); /* Promise resolves to: * { * "_id": "57194b39-c4bc-45a6-a30d-f8e860a020b2", * "_createdDate": "2024-01-10T20:46:38.739Z", * "categoryIds": [ * "c8780752-f517-4cf9-9c18-0f9a22d00926", * "590635d7-cc7c-48cb-970c-f8339daa1cfe", * "2b2ccb5a-e709-45a1-8353-bb3332b91297", * "f2975644-ebb7-475f-baf5-5eb2b195880b" * ], * "changeOrigin": "MANUAL_SAVE", * "commentingEnabled": true, * "contentId": "65a639fd69a6e0d73c4adfad", * "editedDate": "2024-01-16T08:11:09.845Z", * "editingSessionId": "2e890d37-1a69-4153-9cc0-a36ea7e3d4ea", * "excerpt": "No-one can understand the height of it. It required everything from me.", * "featured": false, * "hashtags": [], * "hasUnpublishedChanges": true, * "language": "en", * "media": { * "custom": false, * "displayed": true, * "wixMedia": { * "image": "wix:image://v1/nsplsh_c9fb970af95242248fef3697783cd3db~mv2.jpg/Sunset%20on%20Monterosa.jpg#originWidth=3840&originHeight=5760" * } * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 7, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "settings": { * "keywords": [], * "preventAutoRedirect": false * }, * "tags": [] * }, * "slugs": [], * "status": "UNPUBLISHED", * "tagIds": [ * "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67", * "a55b2c06-cbec-4d01-a8bb-cd7029056c75", * "d2b0c02b-72c1-45af-ba58-3520cec9abe3", * "27f5320b-d91f-4435-9b9b-4b1d41b2ae70" * ], * "title": "Mountain Ranger", * "translations": [], * "url": "https://angeliquefm.wixsite.com/delicious-monster/post/mountain-ranger" * } */ ``` ## Get a draft post (dashboard page example) ```javascript import { draftPosts } from 'wix-blog-backend'; // Sample draftPostId value: "d655251a-74eb-467d-9beb-1962984b8d94" export async function myGetDraftPostFunction(draftPostId) { try { const draftPost = await draftPosts.getDraftPost(draftPostId); console.log('Successfully retrieved the following draft post:', draftPost); return draftPost; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_id": "d655251a-74eb-467d-9beb-1962984b8d94", * "_createdDate": "2023-12-20T16:45:50.910Z", * "categoryIds": [ * "c8780752-f517-4cf9-9c18-0f9a22d00926", * "590635d7-cc7c-48cb-970c-f8339daa1cfe", * "2b2ccb5a-e709-45a1-8353-bb3332b91297", * "f2975644-ebb7-475f-baf5-5eb2b195880b" * ], * "changeOrigin": "MANUAL_SAVE", * "commentingEnabled": true, * "contentId": "65a639b469a6e0d73c4adfa6", * "editedDate": "2024-01-16T08:09:50.581Z", * "editingSessionId": "c8ce3dff-5005-4d40-badf-ceece77bc658", * "featured": false, * "hashtags": [], * "hasUnpublishedChanges": true, * "language": "en", * "media": { * "custom": false, * "displayed": true, * "wixMedia": { * "image": "wix:image://v1/wixsite_524366693776674a6a5559~mv2_d_6000_4000_s_4_2.jpg/orange%20tabby%20kitten%20in%20grasses.jpg#originWidth=6000&originHeight=4000" * } * }, * "memberId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "minutesToRead": 2, * "mostRecentContributorId": "c00e8a5c-322b-4e77-8813-002e3ea7e811", * "pricingPlanIds": [], * "relatedPostIds": [], * "seoData": { * "settings": { * "keywords": [], * "preventAutoRedirect": false * }, * "tags": [] * }, * "seoSlug": "living-from-redemption", * "slugs": [], * "status": "UNPUBLISHED", * "tagIds": [ * "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67", * "a55b2c06-cbec-4d01-a8bb-cd7029056c75", * "d2b0c02b-72c1-45af-ba58-3520cec9abe3" * ], * "title": "The task at hand is worth it!", * "translations": [] * } */ ``` ---