【发布时间】:2018-02-02 20:08:53
【问题描述】:
以下是我的 PostHandler,我试图从我的 React 应用程序中发布博客,但我收到状态代码 405。
postBlogHandler = () => {
const post = {
title: this.state.title,
content: this.state.content,
author: this.state.author
}
axios.post('https://public-api.wordpress.com/rest/v1.2/sites/ishhaanpatel.wordpress.com/posts/new', post)
.then( response => {
console.log(response);
} );
}
以下是回应。
{"error":"unauthorized","message":"该方法不被允许。"}
是否有在线指南可以让我们学习如何使用不同的 API 并掌握发送不同的 HTTP 请求和处理响应?
【问题讨论】:
-
看来您需要访问 oder 会话令牌之类的东西才能在此资源上发布。
-
我相信您需要一些身份验证标头来向 Wordpress API 发出请求。尝试阅读此文档:developer.wordpress.org/rest-api/using-the-rest-api/…
标签: wordpress reactjs post axios