//native
type Buttondown = {
token: string;
};
/**
* Update Tag
*
*/
export async function main(
auth: Buttondown,
id: string,
body: {
name?: string;
color?: string;
description?: string;
secondary_id?: number;
},
) {
const url = new URL(`https://api.buttondown.com/v1/tags/${id}`);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Token " + 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