1
0
mirror of https://github.com/oceanprotocol/community-numbers.git synced 2024-06-20 11:23:11 +02:00
community-numbers/api/networks/bounties.js
2021-11-09 11:04:05 +02:00

32 lines
762 B
JavaScript

import axios from 'axios'
import { log, logError } from '../utils'
const getGitcoin = async () => {
const response = await axios.get(
'https://gitcoin.co/api/v0.1/bounties/?&org=oceanprotocol'
)
if (response.status !== 200) {
logError(`Non-200 response code from Gitcoin: ${response.status}`)
return null
}
const total = response.data
const open = total.filter((item) => item.is_open === true)
return { total: total.length, open: open.length }
}
export default async function fetchBounties() {
const start = Date.now()
const { total, open } = await getGitcoin()
log(
'✓ Bounties. ' +
`Total: ${total} bounties. Open: ${open} bounties. ` +
`Elapsed: ${new Date() - start}ms`
)
return { open, total }
}