GeezerVison is showing hub.windmill.dev — Get form submissions — formstack script | Windmill Hub
Get all submissions for the specified form Script formstack Verified The script Submitted by hugo697 Bun Verified
407 days ago 1 | //native | 2 | type Formstack = { | 3 | token: string; | 4 | }; | 5 | /** | 6 | * /form/:id/submission | 7 | * Get all submissions for the specified form | 8 | */ | 9 | export async function main( | 10 | auth: Formstack, | 11 | id: string, | 12 | encryption_password: string | undefined, | 13 | min_time: string | undefined, | 14 | max_time: string | undefined, | 15 | search_field_x: string | undefined, | 16 | search_value_x: string | undefined, | 17 | page: string | undefined, | 18 | per_page: string | undefined, | 19 | sort: string | undefined, | 20 | data: string | undefined, | 21 | expand_data: string | undefined, | 22 | X_FS_ENCRYPTION_PASSWORD?: string, | 23 | ) { | 24 | const url = new URL( | 25 | `https://www.formstack.com/api/v2/form/${id}/submission.json`, | 26 | ); | 27 | for (const [k, v] of [ | 28 | ["encryption_password", encryption_password], | 29 | ["min_time", min_time], | 30 | ["max_time", max_time], | 31 | ["search_field_x", search_field_x], | 32 | ["search_value_x", search_value_x], | 33 | ["page", page], | 34 | ["per_page", per_page], | 35 | ["sort", sort], | 36 | ["data", data], | 37 | ["expand_data", expand_data], | 38 | ]) { | 39 | if (v !== undefined && v !== "" && k !== undefined) { | 40 | url.searchParams.append(k, v); | 41 | } | 42 | } | 43 | const response = await fetch(url, { | 44 | method: "GET", | 45 | headers: { | 46 | ...(X_FS_ENCRYPTION_PASSWORD | 47 | ? { "X-FS-ENCRYPTION-PASSWORD": X_FS_ENCRYPTION_PASSWORD } | 48 | : {}), | 49 | Authorization: "Bearer " + auth.token, | 50 | }, | 51 | body: undefined, | 52 | }); | 53 | if (!response.ok) { | 54 | const text = await response.text(); | 55 | throw new Error(`${response.status} ${text}`); | 56 | } | 57 | return await response.json(); | 58 | } | 59 |
|
|