0

Clone Form

by
Published Sep 27, 2024

Clone a single form.

Script jotform Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 621 days ago
1
type Jotform = {
2
	apiKey: string
3
	baseUrl: string
4
}
5

6
export async function main(resource: Jotform, formId: string) {
7
	const queryParams = new URLSearchParams({ apiKey: resource.apiKey })
8

9
	const endpoint = `${resource.baseUrl}/form/${formId}/clone?${queryParams.toString()}`
10

11
	const response = await fetch(endpoint, {
12
		method: 'POST'
13
	})
14

15
	if (!response.ok) {
16
		throw new Error(`HTTP error! status: ${response.status}`)
17
	}
18

19
	const data = await response.json()
20

21
	return data
22
}
23