daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var GitHubApi = require('octokit');
  2. retrieveIssues: function(owner, repoName) {
  3.  
  4.   var gh = GitHubApi.new({  
  5.   username: "user",
  6.   password: "password"
  7.   });
  8.  
  9.  
  10.   var repo = gh.getRepo(owner, repoName);
  11.  
  12.   repo.getIssueEvents()
  13.     .then(function(events) {console.log(events)})
  14.  
  15. }
  16.    
  17. npm install @octokit/rest
  18.    
  19. const octokit = require('@octokit/rest')()
  20.  
  21. async function paginate(method) {
  22.     let response = await method({
  23.         owner: "google",
  24.         repo: "gson",
  25.         state: "all",
  26.         per_page: 100
  27.     })
  28.     let {
  29.         data
  30.     } = response
  31.     var count = 0;
  32.     while (octokit.hasNextPage(response)) {
  33.         count++;
  34.         console.log(`${count} request`);
  35.         response = await octokit.getNextPage(response)
  36.         data = data.concat(response.data)
  37.     }
  38.     return data
  39. }
  40.  
  41. paginate(octokit.issues.getForRepo)
  42.     .then(data => {
  43.         console.log(data);
  44.     })
  45.    
  46. const octokit = require('@octokit/rest')()
  47.  
  48. octokit.authenticate({
  49.     type: 'oauth',
  50.     token: 'YOUR_TOKEN'
  51. });
  52.  
  53. async function paginate(method) {
  54.     let response = await method({
  55.         q: "repo:google/gson is:issue",
  56.         per_page: 100
  57.     })
  58.     let data = response.data.items;
  59.     var count = 0;
  60.     while (octokit.hasNextPage(response)) {
  61.         count++;
  62.         console.log(`request n°${count}`);
  63.         response = await octokit.getNextPage(response);
  64.         data = data.concat(response.data.items);
  65.     }
  66.     return data
  67. }
  68.  
  69. paginate(octokit.search.issues)
  70.     .then(data => {
  71.         console.log(data);
  72.         console.log(`retrieved ${data.length} issues`);
  73.     })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top