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

Oct 2017
Oct 18 2017 09:17

Hi, having problem with getting custom endpoint value using this code below:

const wpPromise = '' );

wpPromise.then(function( site ) {
    // If default routes were detected, they are now available
    site.posts().then(function( posts ) {
        console.log( posts );
    }); // etc

    // Namespaces can be saved out to variables:
    var whoisData = site.namespace( 'hosting-review/v1' );
        .domain( '' )
        .then(response => {

Response in console.log I get.

Failed to load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://manpbofjhcdbchabfjffabpfnjgcjmoc' is therefore not allowed access.
Autodiscovery failed
Error: Request has been terminated

I'm trying to do this in an chrome-extension

One of the problems is mode, problem, because I was trying to fetch using fetch. If I change more to no-cors. Then I get empty response, but in development tools network I can see response json.
But I cannot put it into the code.
Oct 18 2017 11:12
solved, added CORS header *
on API
Fabian Perich Lara
Oct 18 2017 19:35

Hi, i need some help. I'm trying to use filter plugin ( but the node-api does not work. I'm using this code.

var WPAPI = require( 'wpapi' ); '' )
    .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)
            category_name: 'guide',
            tag: [ 'ecuador' ]

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.