Open
Description
I'm getting an error message when I'm attempting to update a post.
How do I know if login is successful?
I'm able to get a list of posts so the endpoint works.
I'm using the following:
var wp = new WPAPI({
endpoint: apiRoot,
username: username,
password: credential,
auth: true
});
var test = "posts";
// get posts
if (test=="posts") {
log('verify endpoint')
wp.posts().then(function( response ) {
log("response", response)
}).catch(function(error) {
log("error", error)
})
return;
}
if (test=="update") {
var postNumber = 28;
var date = new Date()
var time = date.getTime();
var update = wp.posts().auth().id( postNumber ).update({
title: "Time " + time
})
.then(function(response){
console.log("complete");
console.log(response);
})
.catch(function(err){
log("error:", err);
});
}
I've installed and activated this plugin.
{ code: 'rest_cannot_edit',
message: 'Sorry, you are not allowed to edit this post.',
data: { status: 401 }
}
Attempting to create a post returns this:
{ code: 'rest_cannot_create',
message: 'Sorry, you are not allowed to create posts as this user.',
data: { status: 401 }
}
I'm using the download of wpapi.js (7/6/2017) here:
http://wp-api.org/node-wpapi/installation/
FYI I'm not on node. I'm in a client that runs ES6.
Metadata
Metadata
Assignees
Labels
No labels