【问题标题】:How to use POST API of wordpress.com to post a blog using Axios in React App?如何使用 wordpress.com 的 POST API 在 React App 中使用 Axios 发布博客?
【发布时间】: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 请求和处理响应?

【问题讨论】:

标签: wordpress reactjs post axios


【解决方案1】:

我需要在 API 端点中包含 API 令牌参数。

【讨论】:

    猜你喜欢
    • 2013-09-19
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多