get parent flow job of suspended job

Script windmill Verified

by admin ยท 8/13/2023

The script

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