0

Get User Reports

by
Published Sep 27, 2024

Gets a list of all reports for an account.

Script jotform Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 620 days ago
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