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 |
|