//native
type Xata = {
apiKey: string
}
/**
* Accept the invitation to join a workspace
* Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
*/
export async function main(auth: Xata, workspace_id: string, invite_key: string) {
const url = new URL(`https://api.xata.io/workspaces/${workspace_id}/invites/${invite_key}/accept`)
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 428 days ago