Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve HTML of ReadMe

Hi so first time working with APIs like this. Anyways, I've been reading up on the GitHub API and came across this:

READMEs support custom media types for retrieving the raw content or rendered HTML.

src: https://developer.github.com/v3/repos/contents/#get-the-readme

Which I believe means that it is possible to retrieve an HTML formatted version of the contents of the README? If so how would I retrieve it using AJAX since the tutorials are all for curl. In the end I want to display a portion of it on my website and would be a lot easier if given in the html format rather then markdown.

The docs say something about: application/vnd.github.VERSION.html

I just don't necessarily know how to use it.

Thanks!

like image 843
Vangogh500 Avatar asked Feb 10 '23 18:02

Vangogh500


1 Answers

You have to set the Accept header of the HTTP request to application/vnd.github.html.

$.ajax({
  url: 'https://api.github.com/repos/just95/toml.dart/readme',
  headers: { 'Accept': 'application/vnd.github.html' }
}).done(function(data) {
  alert(data);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
like image 77
just95 Avatar answered Feb 12 '23 09:02

just95