0
List Tags
One script reply has been approved by the moderators Verified

Returns a list of all tags

Created by hugo697 25 days ago Viewed 10 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 25 days ago
1
type Convertkit = {
2
	apiSecret: string
3
}
4

5
export async function main(resource: Convertkit) {
6
	const queryParams = new URLSearchParams({
7
		api_secret: resource.apiSecret
8
	})
9

10
	const endpoint = `https://api.convertkit.com/v3/tags?${queryParams.toString()}`
11

12
	const response = await fetch(endpoint, {
13
		method: 'GET',
14
		headers: {
15
			'Content-Type': 'application/json'
16
		}
17
	})
18

19
	if (!response.ok) {
20
		throw new Error(`HTTP error! status: ${response.status}`)
21
	}
22

23
	const data = await response.json()
24

25
	return data.tags
26
}
27