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

Fetch all the organisations of current user.

Created by hugo697 86 days ago Viewed 154 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) {
6
	const endpoint = `https://api.certopus.com/v1/organisations`
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