Created
August 20, 2019 09:11
-
-
Save dmail/2b0c0d6fa0940be6646bc0d896469df3 to your computer and use it in GitHub Desktop.
listPullRequestForBranch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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