//native
type Vercel = {
token: string;
};
/**
* Join a team
* Join a team with a provided invite code or team ID.
*/
export async function main(auth: Vercel, teamId: string, body: { inviteCode?: string }) {
const url = new URL(
`https://api.vercel.com/v1/teams/${teamId}/members/teams/join`,
);
const response = await fetch(url, {
method: "POST",
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