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

11th
Dec 2017
carmelolg
@carmelolg
Dec 11 2017 13:54
hi, i'm using the library but i'm not able to use the basic feature.
The response is 403 forbidden but I did the correct auth. I'll post the code
const apiPromise = WPAPI.discover( Parameters.blogsite ).then(function( site ) {
            return site.auth({
                username: Parameters.wpUsername,
                password: Parameters.wpPassword
            });
        });

        // console.log(apiPromise)
        apiPromise.then(function( site ) {
            console.log(site.posts().auth().param( 'status', 'any' ).toString())
            site.posts().then(function( posts ) {
                console.log(posts)
            }).catch(function(err){
                console.log(err) // here is 403 error
            })
         })
someone can help me?
carmelolg
@carmelolg
Dec 11 2017 14:53
it works with almost all, but not with pages and posts.
:(
K Adam White
@kadamwhite
Dec 11 2017 16:19
does it work if you add an 'auth()' onto the chain to site.posts().then...?
carmelolg
@carmelolg
Dec 11 2017 16:40
yes but doesn't work, I tried from browser too (http://carmelolagamba.altervista.org/blog/wp-json/wp/v2/posts)
seems that the service is forbidden