List linkers for an app

Gets a list of all linkers for the authenticated application.

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 linkers for an app
7
 * Gets a list of all linkers
8
for the authenticated application.
9
 */
10
export async function main(auth: Bitbucket) {
11
  const url = new URL(`https://api.bitbucket.org/2.0/addon/linkers`);
12

13
  const response = await fetch(url, {
14
    method: "GET",
15
    headers: {
16
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
17
    },
18
    body: undefined,
19
  });
20
  if (!response.ok) {
21
    const text = await response.text();
22
    throw new Error(`${response.status} ${text}`);
23
  }
24
  return await response.text();
25
}
26