Skip to content

How can I retrieve a draft post? #154

@yongzhihuang

Description

@yongzhihuang
const wp = new WP({
        endpoint: endpoint,
        username: username,
        password: password
});

wp.posts().filter({status: 'any'}).embed().id(id).then(function(data) {
    console.log(data)
})

When I try to retrieve an post that is set to draft, I'm unable to retrieve the post. When I log the error, i got a 403 permission error.

error: 
      { [Error: cannot GET /wp-json/wp/v2/posts/631?_embed=true (403)]
        status: 403,
        text: '{"code":"rest_forbidden","message":"You don\'t have permission to do this.","data":{"status":403}}',
        method: 'GET',
        path: '/wp-json/wp/v2/posts/631?_embed=true' },

The user credential i sent to WP is a user with Admin privilege.

Thank you so much for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions