Lists all users in the account.
1
//native
2
type Vectara = {
3
apiKey: string
4
}
5
/**
6
* List users in the account
7
* Lists all users in the account.
8
*/
9
export async function main(auth: Vectara, limit: string | undefined, page_key: string | undefined) {
10
const url = new URL(`https://api.vectara.io/v2/users`)
11
for (const [k, v] of [
12
['limit', limit],
13
['page_key', page_key]
14
]) {
15
if (v !== undefined && v !== '' && k !== undefined) {
16
url.searchParams.append(k, v)
17
18
19
const response = await fetch(url, {
20
method: 'GET',
21
headers: {
22
'x-api-key': auth.apiKey
23
},
24
body: undefined
25
})
26
if (!response.ok) {
27
const text = await response.text()
28
throw new Error(`${response.status} ${text}`)
29
30
return await response.json()
31
32