//native
type Bitly = {
token: string;
};
/**
* Expand a Bitlink
* Returns the short link and long URL for the specified link.
*/
export async function main(auth: Bitly, body: { bitlink_id?: string }) {
const url = new URL(`https://api-ssl.bitly.com/v4/expand`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago