type Bitbucket = {
username: string;
password: string;
};
/**
* Get an email address for current user
* Returns details about a specific one of the authenticated user's
email addresses.
Details describe whether the address has been confirmed by the user and
whether it is the user's primary address or not.
*/
export async function main(auth: Bitbucket, email: string) {
const url = new URL(`https://api.bitbucket.org/2.0/user/emails/${email}`);
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.json();
}
Submitted by hugo697 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Get an email address for current user
* Returns details about a specific one of the authenticated user's
email addresses.
Details describe whether the address has been confirmed by the user and
whether it is the user's primary address or not.
*/
export async function main(auth: Bitbucket, email: string) {
const url = new URL(`https://api.bitbucket.org/2.0/user/emails/${email}`);
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.json();
}
Submitted by hugo697 935 days ago