Updates a Group Membership.
1
//native
2
type Motimate = {
3
token: string
4
}
5
6
export async function main(
7
auth: Motimate,
8
group_membership_id: string,
9
body: {
10
role?: 'admin' | 'member' | 'observer' | 'super_admin'
11
imported?: false | true
12
13
) {
14
const url = new URL(`https://motimateapp.com/public_api/group_memberships/${group_membership_id}`)
15
16
const response = await fetch(url, {
17
method: 'PATCH',
18
headers: {
19
'Content-Type': 'application/json',
20
Authorization: 'Bearer ' + auth.token
21
},
22
body: JSON.stringify(body)
23
})
24
25
if (!response.ok) {
26
const text = await response.text()
27
throw new Error(`${response.status} ${text}`)
28
29
30
return await response.json()
31
32