0

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?

2
  • there is also a Browser section Commented 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. Commented Aug 28, 2018 at 17:07

1 Answer 1

1

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));
  });

Sign up to request clarification or add additional context in comments.

2 Comments

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?
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.