0

List Locations

by
Published Sep 27, 2024

Returns a list of locations where you can create or replicate databases.

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/locations`
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.locations
23
}
24