Skip to content

Instantly share code, notes, and snippets.

@jvmvl
Forked from derhuerst/output.js
Created October 2, 2019 16:32
Show Gist options
  • Save jvmvl/26b9e184b8c2a5d9195e576f8c95a169 to your computer and use it in GitHub Desktop.
Save jvmvl/26b9e184b8c2a5d9195e576f8c95a169 to your computer and use it in GitHub Desktop.
how fetch a GitHub user's stars
[
{
owner: 'bcoe',
repo: 'top-npm-users',
description: ':star: Generate a list of top npm users by based on monthly downloads.',
language: 'JavaScript',
isFork: false,
stargazers: 27,
watchers: 27
}
// …
]
'use strict'
const got = require('got')
const stars = (user) =>
got(`https://api.github.com/users/${user}/starred`)
.then((res) => JSON.parse(res.body))
.then((starred) => starred.map((s) => ({
owner: s.owner.login
, repo: s.name
, description: s.description
, language: s.language
, isFork: false
, stargazers: s.stargazers_count
, watchers: s.watchers_count
})))
stars('jonschlinkert').then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment