//native
type Clerk = {
apiKey: string;
};
/**
* List all waitlist entries
* Retrieve a list of waitlist entries for the instance.
Entries are ordered by creation date in descending order by default.
Supports filtering by email address or status and pagination with limit and offset parameters.
*/
export async function main(
auth: Clerk,
limit: string | undefined,
offset: string | undefined,
query: string | undefined,
status: "pending" | "invited" | "completed" | "rejected" | undefined,
order_by: string | undefined,
) {
const url = new URL(`https://api.clerk.com/v1/waitlist_entries`);
for (const [k, v] of [
["limit", limit],
["offset", offset],
["query", query],
["status", status],
["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