list inputs for previous completed flow jobs

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * list inputs for previous completed flow jobs
3
 *
4
 */
5
export async function main(
6
  workspace: string,
7
  path: string,
8
  page: string | undefined,
9
  per_page: string | undefined
10
) {
11
  const url = new URL(
12
    `${BASE_URL}/api/w/${workspace}/flows/input_history/p/${path}`
13
  );
14
  for (const [k, v] of [
15
    ["page", page],
16
    ["per_page", per_page],
17
  ]) {
18
    if (v !== undefined && v !== "") {
19
      url.searchParams.append(k, v);
20
    }
21
  }
22
  const response = await fetch(url, {
23
    method: "GET",
24
    headers: {
25
      Authorization: "Bearer " + WM_TOKEN,
26
    },
27
    body: undefined,
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35