如何在 React App 中使用 POST API of wordpress.com to post a blog using Axios?
How to use POST API of wordpress.com to post a blog using Axios in React App?
以下是我的 PostHandler,我试图从我的 React 应用程序 post 博客,但我收到状态代码 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":"That method is not allowed."}
网上有没有教程可以学习如何使用不同的API,掌握发送不同的HTTP请求和处理Response?
我需要在 API 端点包含 API 令牌参数。
以下是我的 PostHandler,我试图从我的 React 应用程序 post 博客,但我收到状态代码 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":"That method is not allowed."}
网上有没有教程可以学习如何使用不同的API,掌握发送不同的HTTP请求和处理Response?
我需要在 API 端点包含 API 令牌参数。