//native
type Vercel = {
token: string;
};
/**
* Delete a Team
* Delete a team under your account. You need to send a `DELETE` request with the desired team `id`. An optional array of reasons for deletion may also be sent.
*/
export async function main(
auth: Vercel,
teamId: string,
newDefaultTeamId: string | undefined,
slug: string | undefined,
body: { reasons?: { slug: string; description: string }[] },
) {
const url = new URL(`https://api.vercel.com/v1/teams/${teamId}`);
for (const [k, v] of [
["newDefaultTeamId", newDefaultTeamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "DELETE",
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