Gets a list of all reports for an account.
1
type Jotform = {
2
apiKey: string
3
baseUrl: string
4
}
5
6
export async function main(resource: Jotform) {
7
const queryParams = new URLSearchParams({ apiKey: resource.apiKey })
8
9
const endpoint = `${resource.baseUrl}/user/reports?${queryParams.toString()}`
10
11
const response = await fetch(endpoint, {
12
method: 'GET',
13
headers: {
14
'Content-Type': 'application/json'
15
16
})
17
18
if (!response.ok) {
19
throw new Error(`HTTP error! status: ${response.status}`)
20
21
22
const data = await response.json()
23
24
return data
25
26