OctoKit NodeJS Get all commits of all repos in user/org

737 views Asked by At

I'm using the NodeJS OctoKit API and for our business analytics I'm trying to gather a list of all commits across all repositories. So I can make a little "ranking".

const owner = req.params.owner;
    const { data } = await octokit.request('GET /user/repos', { type: 'private' })
    let total = 0;
    data.forEach(element => {
        const name = element.name;
        octokit.repos.listCommits({
            owner,
            name,
        }).then(r => {
            total += r.data.length;
        }).catch(error => console.log(error));
    })
    console.log(total);

I tried something like this but it catches load of 404 errors because I think the repos are private

1

There are 1 answers

0
Yoann Maingon On

I guess you solved it by now. How did you initialized octokit? did you put the correct token ?

const octokit = new Octokit({ auth: <githubToken> });