Returns the specific snippet comment.
1
type Bitbucket = {
2
username: string;
3
password: string;
4
};
5
/**
6
* Get a comment on a snippet
7
* Returns the specific snippet comment.
8
*/
9
export async function main(
10
auth: Bitbucket,
11
comment_id: string,
12
encoded_id: string,
13
workspace: string
14
) {
15
const url = new URL(
16
`https://api.bitbucket.org/2.0/snippets/${workspace}/${encoded_id}/comments/${comment_id}`
17
);
18
19
const response = await fetch(url, {
20
method: "GET",
21
headers: {
22
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
23
},
24
body: undefined,
25
});
26
if (!response.ok) {
27
const text = await response.text();
28
throw new Error(`${response.status} ${text}`);
29
}
30
return await response.json();
31
32