0

List Organizations

by
Published Sep 27, 2024

Returns a list of organizations the authenticated user owns or is a member of.

Script turso Verified

The script

Submitted by hugo697 Bun
Verified 621 days ago
1
//native
2
type Turso = {
3
	apiToken: string
4
}
5

6
export async function main(resource: Turso) {
7
	const endpoint = `https://api.turso.tech/v1/organizations`
8

9
	const response = await fetch(endpoint, {
10
		method: 'GET',
11
		headers: {
12
			Authorization: `Bearer ${resource.apiToken}`
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