0
Get Categories
One script reply has been approved by the moderators Verified

Fetch all the categories of an event.

Created by hugo697 19 days ago Viewed 7 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 19 days ago
1
type Certopus = {
2
	apiKey: string
3
}
4

5
export async function main(resource: Certopus, organisationId: string, eventId: string) {
6
	const queryParams = new URLSearchParams({
7
		organisationId,
8
		eventId
9
	})
10

11
	const endpoint = `https://api.certopus.com/v1/categories?${queryParams.toString()}`
12

13
	const response = await fetch(endpoint, {
14
		method: 'GET',
15
		headers: {
16
			accept: 'application/json',
17
			'x-api-key': resource.apiKey
18
		}
19
	})
20

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

25
	const data = await response.json()
26

27
	return data
28
}
29