List default reviewers

Returns the repository's default reviewers. These are the users that are automatically added as reviewers on every new pull request that is created. To obtain the repository's default reviewers as well as the default reviewers inherited from the project, use the [effective-default-reveiwers](#api-repositories-workspace-repo-slug-effective-default-reviewers-get) endpoint.

Script bitbucket Verified

by hugo697 ยท 10/24/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 375 days ago
1
type Bitbucket = {
2
  username: string;
3
  password: string;
4
};
5
/**
6
 * List default reviewers
7
 * Returns the repository's default reviewers.
8

9
These are the users that are automatically added as reviewers on every
10
new pull request that is created. To obtain the repository's default reviewers
11
as well as the default reviewers inherited from the project, use the
12
[effective-default-reveiwers](#api-repositories-workspace-repo-slug-effective-default-reviewers-get) endpoint.
13
 */
14
export async function main(
15
  auth: Bitbucket,
16
  repo_slug: string,
17
  workspace: string
18
) {
19
  const url = new URL(
20
    `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/default-reviewers`
21
  );
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36