fix: surface the message when the check api returns an error (#85)

This commit is contained in:
David Menendez 2018-02-23 01:46:07 -06:00 committed by Mehdi Achour
parent 687194c5f9
commit ab41caa0c7

View file

@ -25,6 +25,9 @@ function getContributorsPage(url) {
})
.then(res => {
const body = JSON.parse(res.body)
if (res.statusCode >= 400) {
throw new Error(body.message)
}
const contributorsIds = body.map(contributor => contributor.login)
const nextLink = getNextLink(res.headers.link)
@ -39,8 +42,6 @@ function getContributorsPage(url) {
}
module.exports = function getContributorsFromGithub(owner, name) {
const url = `https://api.github.com/repos/${owner}/${
name
}/contributors?per_page=100`
const url = `https://api.github.com/repos/${owner}/${name}/contributors?per_page=100`
return getContributorsPage(url)
}