I'm trying to write a static web page that will pull all the current pull requests in a github repo and display them. I would like to use octokit.js But that's for node.js. Is there a straightforward way to make authenticated calls to a github repo form a static webpage?
-
there is also a Browser sectiongaetanoM– gaetanoM2018-08-28 16:57:40 +00:00Commented Aug 28, 2018 at 16:57
-
but no documentation on formats. I don't know node.js syntax. there's only the one call they have written out that I can find.Maxwell Mullin– Maxwell Mullin2018-08-28 17:07:41 +00:00Commented Aug 28, 2018 at 17:07
Add a comment
|
1 Answer
GitHub's API is very open. You can just fetch('https://api.github.com/repos/:user/:repo/pulls'). https://developer.github.com/v3/pulls/#list-pull-requests
Do note that there is a limit on un-authenticated requests, but you shouldn't need to worry about that.
Run the example below to see a list of current pull requests against Node.js core.
fetch('https://api.github.com/repos/nodejs/node/pulls')
.then((r) => r.json())
.then((pulls) => {
pulls
.map((p) => `[${p.number}] ${p.title} (${p.html_url})`)
.forEach((s) => console.log(s));
});
2 Comments
Maxwell Mullin
So I can run the snippet you gave me but when I run it on my enterprise github server I get an error that led me to put the fetch in "no-cors" more: fetch('github.myCompany.com/repos/myUser/repo/pulls', { mode: "no-cors" }) and I get a unexpected end of input. Is there something I'm missing there?
snek
@MaxMullin I don't have access to GitHub enterprise or know anything about the API it exposes. You should edit your question to include that.