Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    K Adam White
    @kadamwhite
    That would be your endpoint, so a .posts() request would yield https://public-api.wordpress.com/wp/v2/sites/myblog.wordpress.com/posts
    There's things that probably won't work because this library was written assuming the normal WordPress API structure, and the addition of the sites/myblog.wordpress.com string following the namespace on .com api endpoints somewhat breaks that assumption. Unfortunately this will likely be a frustration for you.
    @computamike I'd say perhaps it's less "alive" than "on life support;" I do intend to revisit the project this winter, but in the meantime I thank you for your PRs. I have seen them and will merge as soon as I'm able to devote an afternoon to catching up.
    Mees Rutten
    @meesrutten

    Hey! I have a small question about an error i'm facing.

     { 
       code: 'rest_no_route',
       message: 'No route was found matching the URL and request method',
       data: { status: 404 } 
    }

    This happens when I do this in Node:

    const WPAPI =     require( 'wpapi' ),
        ENV =         require( 'dotenv' ).config().parsed
    
    const wp = new WPAPI( {
        endpoint: ENV.WP_API_ENDPOINT,
        username: ENV.WP_API_USERNAME,
        password: ENV.WP_API_PASSWORD,
        auth: true
    } )
    
    wp.pages().get().then( data => {
        // do something with the returned posts
        console.log( data )
    
    } ).catch( err => {
        console.log( err )
    } )
    But the thing is, when I navigate to the endpoint i'm using https://website/index.php/wp-json/wp/v2/pages/6 I can see the JSON correctly
    K Adam White
    @kadamwhite
    @meesrutten What is the value of ENV.WP_API_ENDPOINT?
    Mees Rutten
    @meesrutten
    When I navigate there it shows me the JSON, so the link isn't broken
    K Adam White
    @kadamwhite
    @meesrutten the endpoint should only be the piece ending in wp-json; if you console.log(
    console.log( wp.pages().toString() )`
    Mees Rutten
    @meesrutten
    I'll try!
    K Adam White
    @kadamwhite
    I suspect you may see that you’re getting a URL like https://website/index.php/wp-json/wp/v2/pages/6/wp/v2/pages. You should set the endpoint to only https://website/index.php/wp-json
    Forgive the poor formatting, trying to use gitter via mobile web ;)
    Mees Rutten
    @meesrutten
    ah it seems to work
    Do you know how I can get a certain page by ID?
    wp.pages().id(6).then(...) seems to do the trick
    Mees Rutten
    @meesrutten
    @kadamwhite it works now! Thank you so much :)
    BTW, love the node-wpapi! My clients still get WordPress and I don't get the headache of WordPress :)
    Praful
    @Praful
    @jlalvarez18 thanks for replying.
    @kadamwhite I've switched to developing in a local Docker WordPress install now! However, for others, I used endpoint https://praful.home.blog/?rest_route=/' since my test site on WordPress.com is praful.home.blog. I also used http://prafulhome.wordpress.com/wp-json.
    Praful
    @Praful

    @kadamwhite On another note, I want to add an image to a post. I copied the example you provide in which you create a media object then update the post attribute. This has no effect on the post.

    How do I create a post with text followed by one or more photos at the bottom? Also how do I create a gallery post?!

    Thanks!

    Juan Adolfo
    @2Jacz
    can someone make me a demo?
    im new with wordpress rest api and im trying to use the wpapi client but cant make it work :s
    gonzalobarria
    @gonzalobarria
    Hi! I would like to know how call POST method on a

    Hi! I would like to know how call POST method on a registerRoute.

    I'm trying to use JWT Authentication for WP-API and I want to get the token

    wp.token = wp.registerRoute('jwt-auth/v1', '/token');

    const token = await wp.token();

    Kada6
    @Kada6_gitlab
    hello
    i have trouble with posting through api {
    code: 'rest_cannot_create',
    message: 'Sorry, you are not allowed to create posts as this user.',
    data: { status: 401 }
    }
    Iv tried several accounts, no results. basic auth plugin is installed and activated
    Ivan Jeremic
    @ivanjeremic
    I try to get the user-role of current authenticated user can anyone give me a hint I can't find out where it is I tried without seccess.
    Diego Aguilar Aguilar
    @diegoaguilar
    Hello, I want to fetch a landing_page Post Type
    I can find the Custom PostType via wp.types().type( 'landing_page' ).embed()
    but not sure how I should fetch all of this tyope
    Eric Howard
    @thelucre
    is it possible to chain .embed() to a custom registered route?
    Lawrence Kimsey
    @lkimsey
    Has anyone completed Zach Gordon's WordPress REST Complete Beginners Guide ?
    Helder Oliveira
    @heldrida
    When creating an image, the document example works but only generates a single featuredImage and I need to have different sizes, like thumb, small, large etc. If I use the wordpress UI and set a featured image this happens automatically. But no sure how to do it programmatically.
    Air
    @yunair
    Hello, I want to create a post with js code, If i put my code in content, I can't edit it in user publish page anymore. What's the right way to do ?
    smartm0use
    @smartm0use
    hello, is it possible to get help here?
    I'm having problem with this: WP-API/node-wpapi#455
    smartm0use
    @smartm0use
    @kadamwhite
    Shahriar Shojib
    @shahriar-shojib
    when you use error to your advantage πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚
    await wp.categories().create({
    name: categoryName
    }).then(res => {
    categoryID = res.id; // sets categoryID to the newly created id
    }).catch(err => {
    categoryID = err.data.term_id // sets categoryID to existing ID πŸ˜‚πŸ˜‚
    });
    lstoyanoff
    @lstoyanoff
    @kadamwhite Hey, I'm trying to use wp.media().file() in RN (if that even matters). I've tried passing both path and File with no success. When I pass path the WP REST API respond with rest_upload_no_data and if I pass a File Object I get the following message File is empty. Please upload something more substantial..... I've tried using a simple fetch request with FormData and it works fine. Am I doing something wrong or there is some kind of limitation when node-wpapi is used in RN? Thank you!
    Valentin P.
    @vpuls
    Hey there, I'm new to node-wpapi and like it but I can't find an answer to a supposedly easy question: Is it possible to reduce the WP API response to only needed fields with node-wpapi? The WP REST API Doc features the _fields query param (see https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields), but in the node-wpapi doc I can't find related information. Any help appreciated, thanks in advance!
    Valentin P.
    @vpuls

    Hey there, I'm new to node-wpapi and like it but I can't find an answer to a supposedly easy question: Is it possible to reduce the WP API response to only needed fields with node-wpapi? The WP REST API Doc features the _fields query param (see https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields), but in the node-wpapi doc I can't find related information. Any help appreciated, thanks in advance!

    I guess I found it out on my own by playing around and reading code on Github. For anyone asking him/herself the same question I did: You can use WPRequest.param() method as in this example:

    wpapi.pages().param('_fields', 'id,slug,title,parent').

    The wordpress API will return a JSON with all pages in it but for each page only the parameters id, slug, title and parent are listed. So far it tested it with WPReuqest objects returned by wpapi.root(), wpapi.pages().orderby().order() and wpapi.post() and it seems to work as I intended, reducing the JSON download size and thus the loading time.

    Negocios rentables
    @Negocios201X_twitter
    Hello, how can I create a post with a post type other than "post"?
    Luis Miguel Urbina Rodriguez
    @urbinadeveloper_twitter
    I was already able to create a post with a different post type, but the image is not attached.

    wp.productsAPI = wp.registerRoute("wp/v2", "/wp-manga/");
    wp.productsAPI().create({

    title: 'Your Post Title2',
    content: 'Your post content2',
    status: 'publish'

    }).then(function(post) {
    console.log("post", post, "post");

    return wp.media().file('prueba.png').create({
    title: 'Amazing featured image',
    post: post.id
    })

    }).then(function(media) {

                          // Set the new media record as the post's featured media
                          return wp().posts().id(post.id).update({
                            featured_media: media.id
                          });

    });

    Luis Miguel Urbina Rodriguez
    @urbinadeveloper_twitter
    Please.
    Mystiq
    @JakubSladek

    Hey, what to do? I never got that error before, can't fetch or update any posts, I changed nothing, yesterday worked normally and idk what to do.

    node_modules\superagent\lib\request-base.js:342 this._header[field.toLowerCase()] = val; ^ TypeError: Cannot set property 'authorization' of undefined
    Code:

    this.wp.series()
                    .param("status", "any")
                    .then(async (series) => {
                        let result = await getOnlyNeededInfo(series);
                        resolve(result);
                    })
                    .catch((err) => {
                        this.handleError(err);
                        resolve(false);
                    });
    Alessandro Manias
    @alessandro.manias.gag_gitlab
    Good morning, is possible to use wpapi to make call to jwt.auth plugin route and generate the jwt token?
    Andrew L Webber
    @kadadji:matrix.org
    [m]
    hello, anybode here?