简体   繁体   中英

How to use POST API of wordpress.com to post a blog using Axios in React App?

Following is my PostHandler, where I am trying to post a blog from my React App but I am getting status code 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);
    } );
}

And following was the response.

{"error":"unauthorized","message":"That method is not allowed."}

Is there a guide online that we can learn from how to use different APIs and master sending different HTTP requests and handling Response?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM