Need API to get "Post object by passing only post id"



  • Hi,

    We need API to get "Post object by passing only post id".
    We have search around source code but we have not found any API which fullfil our requirement.

    Please let us know about this api.
    And also how we can find/use existing api into our plugin.

    Any help would be greatly appreciated.
    Thanks!!!


  • Global Moderator

    The API already exists here

    What you do is, first require the API module:

    var posts = module.parent.require("./posts"); // requires "/src/posts.js"
    
    posts.getPostData(pid, function(err, postObject){
      if(err){
        // there was some sort of error
        return;
      }
      // do stuff with postData
    });


  • Hi,

    Thanks for the reply,
    But We need to call this API from wordpress plugin.
    Please tell us 'REST' API which we can call from wordpress plugin.

    Thanks!!


  • Admin

    This is possible on latest now. The route is /api/post/:pid



  • Thanks for reply,

    I have updated version 0.6.1 but that API is not working.
    Error:
    {
    "path": "/api/post/492",
    "error": "not-found"
    }

    So can you please tell me which version your are using? If possible please provide me URL for source code.

    Thanks!!


  • Admin

    @akumbhare It will be available in v0.7.0.


 

Suggested Topics

| |