//native
type Planetscale = {
serviceTokenId: string;
serviceToken: string;
};
/**
* Get an organization
*
### Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
**Service Token Accesses**
`read_organization`
**OAuth Scopes**
| Resource | Scopes |
| :------- | :---------- |
| User | `read_organizations` |
| Organization | `read_organization` |
*/
export async function main(auth: Planetscale, name: string) {
const url = new URL(`https://api.planetscale.com/v1/organizations/${name}`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `${auth.serviceTokenId}:${auth.serviceToken}`,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago