You get an 401 because your AJAX isn’t authorized to delete Posts. Would be a big Problem, if everyone could send such Kind of AJAX-requests to your WordPress and delete all your Content.
As of the API, your JS code has to be modifyed to something like this:
...
//make the request
var dataArray = {};
var urlRequest = WP_API_Settings.root+"/posts/"+postID;
var typeRequest="DELETE";
//first set the standard stuff
dataArray["action"] = "wp_api";
//dataArray["_wp_json_nonce"] = WP_API_Settings.nonce;
//make the post
$.ajax(urlRequest,{
url : urlRequest,
type : typeRequest,
data : dataArray,
cache : false,
beforeSend: function (xhr) {
xhr.setRequestHeader('X-WP-Nonce', WP_API_Settings.nonce);
if (beforeSend) {
return beforeSend.apply(this, arguments);
}
}
}).done(
....
So now your NONCE is set in the X-WP-Nonce Header instead as an variable in the data.
May that works, I didn’t tested it.