Skip to content

Commit

Permalink
Fix detection of users vs orgs in GH API
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom committed Nov 6, 2023
1 parent 1312238 commit f9d5eaa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ async function fetchGithub(url) {
if (!repo) {
// Fetch info on all repos from the org / the user
let ownerType = "orgs";
const r= await authedFetch(`https://api.github.com/orgs/${owner}`);
if (r.status === 404) ownerType = 'users';
try {
const r= await authedFetch(`https://api.github.com/orgs/${owner}`);
} catch (e) {
ownerType = 'users';
}
const repos = await recursiveGhFetch(`https://api.github.com/${ownerType}/${owner}/repos?per_page=100&direction=asc`);
const items = await Promise.all(repos.filter(r => !r.fork).map(r => r.owner ? fetchGithubRepo(r.owner.login, r.name) : []));
// TODO: this should instead be sent as a collection of services (1 per repo)
Expand Down

0 comments on commit f9d5eaa

Please sign in to comment.