//native
type Clerk = {
apiKey: string;
};
/**
* Get a list of organizations for an instance
* This request returns the list of organizations for an instance.
Results can be paginated using the optional `limit` and `offset` query parameters.
The organizations are ordered by descending creation date.
Most recent organizations will be returned first.
*/
export async function main(
auth: Clerk,
limit: string | undefined,
offset: string | undefined,
include_members_count: string | undefined,
query: string | undefined,
order_by: string | undefined,
) {
const url = new URL(`https://api.clerk.com/v1/organizations`);
for (const [k, v] of [
["limit", limit],
["offset", offset],
["include_members_count", include_members_count],
["query", query],
["order_by", order_by],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago