//native
type Cohere = {
apiKey: string;
};
/**
* List Connectors
* Returns a list of connectors ordered by descending creation date (newer first). See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.
*/
export async function main(
auth: Cohere,
limit: string | undefined,
offset: string | undefined,
) {
const url = new URL(`https://api.cohere.com/v1/connectors`);
for (const [k, v] of [
["limit", limit],
["offset", offset],
]) {
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