0
Update tag
One script reply has been approved by the moderators Verified

Updates a tag

Created by hugo697 48 days ago Viewed 4310 times
0
Submitted by hugo697 Bun
Verified 48 days ago
1
//native
2
type Adhook = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Adhook,
8
	id: string,
9
	body: {
10
		id?: string
11
		userId?: string
12
		tenantId?: string
13
		subtenantId?: string
14
		text?: string
15
		color?: string
16
	}
17
) {
18
	const url = new URL(`https://app.adhook.io/v1/tags/${id}`)
19

20
	const response = await fetch(url, {
21
		method: 'PUT',
22
		headers: {
23
			Authorization: `Bearer ${auth.token}`,
24
			'Content-Type': 'application/json'
25
		},
26
		body: JSON.stringify(body)
27
	})
28

29
	if (!response.ok) {
30
		const text = await response.text()
31
		throw new Error(`${response.status} ${text}`)
32
	}
33

34
	return await response.json()
35
}
36