Github Restful API is convenient to use:

For example, read the details of user I042416 using the restful API:

Api.github.com/users/i0424…

Or read the first issue of the repository at KnowledgeRepository:

Api.github.com/repos/i0424…

www.jianshu.com/p/a0c7d0482…

I need to print out the title property:

Body is the body field:

Source code is as follows:

var request = require('request');

var url = "https://api.github.com/repos/i042416/KnowlegeRepository/issues/2214";



var getIssueOptions = {
        url: url,
        method: "GET".json:true.headers: {
            "User-Agent": "Mozilla / 5.0 (Windows NT 10.0; Win64; X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"}};function getIssue() {
  return new Promise(function(resolve,reject){
      var requestC = request.defaults({jar: true});
      console.log("Step1: get issue via url: " + url );

      requestC(getIssueOptions,function(error,response,body){
        if(error){
          console.log("error occurred: " + error);
          reject(error);
        }
        console.log("title:" + body.title);
        console.log("body: " + body.body);
      }); 
     });
}

function displayResult(oResult){
  // console.log(oResult);
  var size = oResult.d.results.length;

  for( var i = 0; i < size; i++){
    var item = oResult.d.results[i];
    console.log("city: " + item.City);
    console.log("ContactLevelName: " + item.ContactLevelName);
  }
}

getIssue();
Copy the code

Effect after implementation:

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: