//native
type Discourse = {
apiKey: string;
defaultHost: string;
apiUsername: string;
};
/**
* Remove a topic
*
*/
export async function main(
auth: Discourse,
id: string,
) {
const url = new URL(`https://${auth.defaultHost}/t/${id}.json`);
const response = await fetch(url, {
method: "DELETE",
headers: {
"API-KEY": auth.apiKey,
"API-USERNAME": auth.apiUsername,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago