These are chat archives for WP-API/node-wpapi

23rd
Nov 2017
jdzorg
@jdzorg
Nov 23 2017 12:56

Hi, i need some help. I'm trying to use filter plugin (https://github.com/wp-api/rest-filter) but the node-api does not work. I'm using this code.

var WPAPI = require( 'wpapi' );

WPAPI.discover( 'https://www.verygood.travel/blog' )
    .then(function( wp ) {
        // Query by the slug of a category or tag
        // Get all posts in category "islands" and tags "clouds" & "sunset"
        // (filter can either accept two parameters, as above where it's called with
        // a key and a value, or an object of parameter keys and values, as below)
        wp.posts().filter({
            category_name: 'guide',
            tag: [ 'ecuador' ]
        }).then(function(posts){
            console.log(posts)
        })        
    });

the filter() function appears to do nothing or maybe in a loop. If i remove the filter function, works well.

if you go to this request
you will se filter plugin it is working well.

Could you help me please.
Thanks

Hello! I've the same problem, but I'm trying to use 'meta_query' (I've allowed it by using this plugin https://github.com/WP-API/rest-filter). If I get filter[meta_query][0][key]=_bit_rooms&filter[meta_query][0][value]=2 it's work, but by .filter({'meta_query': [
{
'key': '_bit_rooms',
'value': '2',
'compare': '='
}
]}) it's don't want to work