gh-card
gh-card copied to clipboard
Add suggestions drop-down to search box
@ISNIT0 Thank you very much for your idea! The search box is a very helpful feature for users because they use it even if they forget some part of repo name.
However, search in GitHub API is very limited to request, 30req/min. So, I think it is not a realistic way to implement in current status. If this app is OAuth app and has user's tokens, this feature may be realistic, I think.
I think you might be able to use this: https://developer.github.com/v3/repos/#list-user-repositories (Probably in conjunction with the org request too)...
E.g. this works without a key: https://api.github.com/users/nwtgck/repos
// debounced...
if(term.includes('/')) {
const [userOrOrg] = term.split('/');
const resultsArr = await Promise.all([
fetch(`https://api.github.com/users/${userOrOrg}/repos`).then(a => a.json()),
fetch(`https://api.github.com/orgs/${userOrOrg}/repos`).then(a => a.json())
])
const results = resultsArr.flat();
search.suggest(results);
}
@ISNIT0 You are right! I was wrong.
The search feature can be done on the client side! It doesn't consume the rate-limit of server-side at all. This feature is very realistic. I'd like to have this feature in the future.