//native
type Vercel = {
token: string;
};
/**
* Delete one or more Edge Config tokens
* Deletes one or more tokens of an existing Edge Config.
*/
export async function main(
auth: Vercel,
edgeConfigId: string,
teamId: string | undefined,
slug: string | undefined,
body: { tokens: string[] },
) {
const url = new URL(
`https://api.vercel.com/v1/edge-config/${edgeConfigId}/tokens`,
);
for (const [k, v] of [
["teamId", teamId],
["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.text();
}
Submitted by hugo697 428 days ago