//native
type Buttondown = {
token: string;
};
/**
* List Comments
*
*/
export async function main(
auth: Buttondown,
email_id: string | undefined,
subscriber_id: string | undefined,
expand: string | undefined,
ordering: string | undefined,
) {
const url = new URL(`https://api.buttondown.com/v1/comments`);
for (const [k, v] of [
["email_id", email_id],
["subscriber_id", subscriber_id],
["expand", expand],
["ordering", ordering],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Token " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago