Gab*_*rit 5 javascript json gist github
我正在尝试通过javascript创建一个公共要点.我没有使用任何身份验证 - 这都是客户端.
var gist = {
"description": "test",
"public": true,
"files": {
"test.txt": {
"content": "contents"
}
}
};
$.post('https://api.github.com/gists', gist, function(data) {
});
Run Code Online (Sandbox Code Playgroud)
上面的代码抛出400:错误的请求 - 解析JSON的问题.但是,我的JSON是有效的.有任何想法吗?
Gab*_*rit 10
啊哈 - 我无法将对象传递给$ .post.它需要首先进行字符串化:
var gist = {
"description": "test",
"public": true,
"files": {
"test.txt": {
"content": "contents"
}
}
};
$.post('https://api.github.com/gists', JSON.stringify(gist), function(data) {});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1052 次 |
| 最近记录: |