Javascript 有没有办法从wordpress api获取待处理的评论/帖子?

Javascript 有没有办法从wordpress api获取待处理的评论/帖子?,javascript,wordpress,wordpress-rest-api,Javascript,Wordpress,Wordpress Rest Api,我正试图从wordpress API中获取待定的评论/帖子。 当我键入此选项时,它只返回已发布的项目。有没有办法获取待处理的项目?我正在尝试做的是在我的应用程序中从挂起更改为发布 编辑: 我被认证了 我在wordpress的functions.php中添加了以下代码: wp_enqueue_脚本('custom_js',get_template_directory_uri()。/js/custom.js',NULL,1.0,true); wp_本地化_脚本('custom_js','magica

我正试图从wordpress API中获取待定的评论/帖子。 当我键入此选项时,它只返回已发布的项目。有没有办法获取待处理的项目?我正在尝试做的是在我的应用程序中从挂起更改为发布

编辑: 我被认证了 我在wordpress的functions.php中添加了以下代码:

wp_enqueue_脚本('custom_js',get_template_directory_uri()。/js/custom.js',NULL,1.0,true);
wp_本地化_脚本('custom_js','magicalData',数组(
“nonce”=>wp\u create\u nonce(“wp\u rest”),
));
在我的custom.js中,我有:

fetch("http://localhost/testWeb/wp-json/wp/v2/comments?status=pending", {
  method: "GET",
  headers: {
    "Content-Type": "application/json; charset=UTF-8",
    "X-WP-Nonce": magicalData.nonce  //authorization 
  }
})
  .then(res => res.json())
  .then(data => console.log(data));  // t

我仍然什么也没有得到(空对象,尽管我在wordpress面板中有一条待处理的注释)

您必须通过身份验证才能访问待处理的注释


您是否尝试过/comments?status=pendingNo它不起作用。当我查询:/comments?status=pending时,我得到以下响应:{“代码”:“rest\u probled\u param”,“消息”:“查询参数不允许:status”,“data”:{“status”:401}