api 是 v3,我试图制作一个工具的原因是当你输入你的 github 用户名和密码以及 repo 名称和描述时,它会初始化 repo 并给你 url。我的输入是这个 -
curl -u {myuser}:{mypassword} -H "Content-Type: application/json" -d '{"name":"api-test","description":"made with github api","homepage": "https://github.com","private":true}' POST https://api.github.com/users/{myuser}/repos
Run Code Online (Sandbox Code Playgroud)
我得到回应
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
Run Code Online (Sandbox Code Playgroud)
. 文档是这样说的:为经过身份验证的用户创建一个新的存储库。POST /用户/存储库。https://developer.github.com/v3/repos/#create。我对 github-api 很陌生,感谢您的帮助。
错误是渲染返回函数中的意外标记,预期为“,”。我正在使用 babel 并将此文件链接到一个 html 文件中。我删除了评论类和组件以供查看。我也删除了评论表单组件。
这是 main.js:
class App extends React.Component {
constructor(props) {
super(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.state = { comments : [] }
}
handleSubmit(event) {
// ...
}
render() {
const comments = this.state.comments.map((comment) => {
<Comment author={comment.author} message={comment.message} />
});
const formcomment = <CommentForm handleSubmit = {this.handleSubmit} />;
return (
{comments}
{formcomment} // ERROR HERE
)
}
}
ReactDOM.render(<App />, document.getElementById("root"))
Run Code Online (Sandbox Code Playgroud)