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

25th
Mar 2018
Dignity1988
@Dignity1988
Mar 25 2018 19:08
Hello i i am tryiing to make it from gunt tasks function but cannot even test the responss. I only get Promises as answer
Running "post" task
Promise { '': 4, _state: undefined, _result: undefined, _subscribers: [] }

grunt.task.registerTask('post', function (){

var WPAPI = require( 'wpapi' );
var wp = new WPAPI({
endpoint: 'http://new.whiteraven.org.ua/wp-json',
// This assumes you are using basic auth, as described further below
username: 'maksym',
password: '1234567890',
auth: true

});

var _p = wp.posts().create({
title:'test',
content:'test content'
})
.then(function(response){
console.log("complete");
console.log(response);
})
.catch(function(err){
// handle error
console.log("ERROR:");
console.log(err.response.text);
});

console.log(_p);

});

the answer is present from the real site and route is fine. Do i need to specify the route?