Created
July 19, 2023 20:07
-
-
Save saggie/4f1309641caeafb934079f422bca20e1 to your computer and use it in GitHub Desktop.
Get a list of pull request comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Octokit } from "@octokit/rest"; // Required: `npm install @octokit/rest --save` | |
const octokit = new Octokit({ | |
auth: "github_pat_xxxxx", // Specify your personal access token here | |
}); | |
const response = await octokit.request( | |
"GET /repos/__OWNER__/__REPO__/pulls/comments", | |
{ | |
owner: "__OWNER__", | |
repo: "__REPO__", | |
headers: { | |
"X-GitHub-Api-Version": "2022-11-28", | |
}, | |
} | |
); | |
const result = response.data | |
.map((it) => { | |
// Extract attributes | |
return { | |
user: it.user.login, | |
body: it.body, | |
url: it.html_url, | |
}; | |
}) | |
.filter((it) => it.user === "saggie"); // Filer by user | |
console.log(JSON.stringify(result)); | |
// [ | |
// { | |
// "user":"saggie", | |
// "body":"Moi!", | |
// "url":"https://github.com/__OWNER__/__REPO__/pull/1#discussion_r1234567890" | |
// }, | |
// ... | |
// ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment