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

Fetch all the events for an organisation.

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

5
export async function main(resource: Certopus, organisationId: string) {
6
	const endpoint = `https://api.certopus.com/v1/events/${organisationId}`
7

8
	const response = await fetch(endpoint, {
9
		method: 'GET',
10
		headers: {
11
			accept: 'application/json',
12
			'x-api-key': resource.apiKey
13
		}
14
	})
15

16
	if (!response.ok) {
17
		throw new Error(`HTTP error! status: ${response.status}`)
18
	}
19

20
	const data = await response.json()
21

22
	return data
23
}
24