type Bitbucket = {
username: string;
password: string;
};
/**
* Watch an issue
* Start watching this issue.
To start watching this issue, do an empty PUT. The 204 status code
indicates that the operation was successful.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/watch`
);
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 396 days ago