[英]How can I get all the information from the GitHub API
我有一個問題。 我在公共 GitHub API 上使用 vanilla JavaScript 發出 GET 請求,我得到了響應,但不是單個用戶的完整信息。 如何獲取 Twitter 用戶名或 Twitter 帳戶鏈接等所有信息?
這是我的代碼以防萬一:
function loadUsers() {
const xhr = new XMLHttpRequest();
const URL = 'https://api.github.com/users';
xhr.open('GET', URL, true);
xhr.onload = function() {
if(this.status == 200) {
let users = this.responseText;
console.log(users);
}
}
xhr.send();
}
對於每個用戶,您都會收到 url 以了解更多詳細信息 api。 在您的示例中,第一個用戶有
{
...
"url": "https://api.github.com/users/mojombo",
...
},
Or just follow the schema https://api.github.com/users/{username}
If you call this url ( try ), you will get the twitter account and more.
{
"login": "mojombo",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/1?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mojombo",
"html_url": "https://github.com/mojombo",
"followers_url": "https://api.github.com/users/mojombo/followers",
"following_url": "https://api.github.com/users/mojombo/following{/other_user}",
"gists_url": "https://api.github.com/users/mojombo/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mojombo/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mojombo/subscriptions",
"organizations_url": "https://api.github.com/users/mojombo/orgs",
"repos_url": "https://api.github.com/users/mojombo/repos",
"events_url": "https://api.github.com/users/mojombo/events{/privacy}",
"received_events_url": "https://api.github.com/users/mojombo/received_events",
"type": "User",
"site_admin": false,
"name": "Tom Preston-Werner",
"company": "@chatterbugapp, @redwoodjs, @preston-werner-ventures ",
"blog": "http://tom.preston-werner.com",
"location": "San Francisco",
"email": null,
"hireable": null,
"bio": null,
"twitter_username": "mojombo",
"public_repos": 62,
"public_gists": 62,
"followers": 22447,
"following": 11,
"created_at": "2007-10-20T05:24:19Z",
"updated_at": "2021-03-18T22:50:53Z"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.