type Bitbucket = {
username: string;
password: string;
};
/**
* Check if the current user is watching a snippet
* Used to check if the current user is watching a specific snippet.
Returns 204 (No Content) if the user is watching the snippet and 404 if
not.
Hitting this endpoint anonymously always returns a 404.
*/
export async function main(
auth: Bitbucket,
encoded_id: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/snippets/${workspace}/${encoded_id}/watch`
);
const response = await fetch(url, {
method: "GET",
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.text();
}
Submitted by hugo697 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Check if the current user is watching a snippet
* Used to check if the current user is watching a specific snippet.
Returns 204 (No Content) if the user is watching the snippet and 404 if
not.
Hitting this endpoint anonymously always returns a 404.
*/
export async function main(
auth: Bitbucket,
encoded_id: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/snippets/${workspace}/${encoded_id}/watch`
);
const response = await fetch(url, {
method: "GET",
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.text();
}
Submitted by hugo697 935 days ago