【问题标题】:Is it Possible to Fetch Users fro Github Api by users Location是否可以按用户位置从 Github Api 获取用户
【发布时间】:2018-10-17 08:59:07
【问题描述】:

是否可以通过用户位置从 Github Api 获取用户?

下面的代码通过用户名获取用户:

async getUser(user) {
    const profileResponse = await fetch(`https://api.github.com/users/${user}?client_id=${this.client_id}&client_secrets=${this.client_secret}`);

    const profile = await profileResponse.json();

    return {
        profile
    }
}

我目前正在做一个 Github Api 项目。

【问题讨论】:

  • async getUser(user){ const profileResponse = await fetch(https://api.github.com/users/${user}?client_id=${this.client_id}&client_secrets=${this.client_secret}); const profile = 等待 profileResponse.json(); return{ profile } } // 该代码在单个用户上获取
  • 你试过documentation吗?不是answer your question吗?

标签: git github github-api


【解决方案1】:

您可以使用 Github search users APIlocation 搜索词:

https://api.github.com/search/users?q=location:france

使用javascript:

var country = "france";
fetch(`https://api.github.com/search/users?q=${encodeURIComponent(`location:${country}`)}`)
    .then(res => res.json())
    .then(data => console.log(data))
    .catch(err => console.error(err));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多