| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
|
| 3 |
const postTypes = { page: 'pages', post: 'posts' }; |
| 4 |
|
| 5 |
// status should only be either "publish" or "draft" |
| 6 |
export default async ({ postId, postType }) => { |
| 7 |
const type = postTypes[postType] || postType; |
| 8 |
const response = await apiFetch({ |
| 9 |
path: `/wp/v2/${type}/${postId}?context=view`, |
| 10 |
}); |
| 11 |
|
| 12 |
return { post_status: response.status }; |
| 13 |
}; |
| 14 |
|