Skip to content

Instantly share code, notes, and snippets.

@dmail
Created August 20, 2019 09:11
Show Gist options
  • Save dmail/2b0c0d6fa0940be6646bc0d896469df3 to your computer and use it in GitHub Desktop.
Save dmail/2b0c0d6fa0940be6646bc0d896469df3 to your computer and use it in GitHub Desktop.
listPullRequestForBranch
// https://developer.github.com/v3/pulls/#list-pull-requests
const fetch = require("node-fetch")
const listPullRequestForBranch = async ({ token, repoOwner, repoName, head }) => {
try {
const href = `https://api.github.com/repos/${repoOwner}/${repoName}/pulls?head=${encodeURIComponent(
head,
)}`
const response = await fetch(href, {
headers: {
authorization: `token ${token}`,
},
method: "GET",
})
const status = response.status
const responseBodyAsJSON = await response.json()
if (status !== 200) {
console.log({
status,
responseBodyAsJSON,
})
}
return responseBodyAsJSON
} catch (e) {
throw e
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment