get resume urls given a job_id, resume_id and a nonce to resume a flow

Script windmill Verified

by admin ยท 8/13/2023

The script

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