//native
type Clerk = {
apiKey: string;
};
/**
* Get a list of organization invitations for the current instance
* This request returns the list of organization invitations for the instance.
*/
export async function main(
auth: Clerk,
limit: string | undefined,
offset: string | undefined,
order_by: string | undefined,
status: "pending" | "accepted" | "revoked" | undefined,
query: string | undefined,
) {
const url = new URL(`https://api.clerk.com/v1/organization_invitations`);
for (const [k, v] of [
["limit", limit],
["offset", offset],
["order_by", order_by],
["status", status],
["query", query],
]) {
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