//native
/**
* List Bases
* List the bases the token can access, with each base's ID and permission level. Requires the schema.bases:read scope.
*/
export async function main(auth: RT.Airtable) {
const bases: any[] = []
let offset: string | undefined = undefined
do {
const url = new URL("https://api.airtable.com/v0/meta/bases")
if (offset) {
url.searchParams.append("offset", offset)
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.apiKey}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const page = await response.json()
bases.push(...(page.bases ?? []))
offset = page.offset
} while (offset)
return { bases }
}
Submitted by hugo989 3 hours ago