mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
github api example
This commit is contained in:
17
docs/examples/github_api/index.js
Normal file
17
docs/examples/github_api/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import _ from 'https://unpkg.com/lodash-es'
|
||||
|
||||
async function getPopularLanguages() {
|
||||
const url = 'https://api.github.com/search/repositories?q=stars:%3E1&sort=stars'
|
||||
const resp = await fetch(url)
|
||||
const repos = await resp.json()
|
||||
return _(repos.items)
|
||||
.map(r => r.language)
|
||||
.filter(l => l != null)
|
||||
.countBy()
|
||||
.toPairs()
|
||||
.sortBy(([lang, useCount]) => useCount)
|
||||
.map(([lang]) => lang)
|
||||
.value()
|
||||
}
|
||||
|
||||
await getPopularLanguages()
|
||||
Reference in New Issue
Block a user