raw script by path with a token (mostly used by lsp to be used with import maps to resolve scripts)

Script windmill Verified

by admin ยท 8/13/2023

The script

Submitted by admin Typescript (fetch-only)
Verified 370 days ago
1
/**
2
 * raw script by path with a token (mostly used by lsp to be used with import maps to resolve scripts)
3
 *
4
 */
5
export async function main(workspace: string, token: string, path: string) {
6
  const url = new URL(
7
    `${BASE_URL}/api/scripts_u/tokened_raw/${workspace}/${token}/${path}`
8
  );
9

10
  const response = await fetch(url, {
11
    method: "GET",
12
    headers: {
13
      Authorization: "Bearer " + WM_TOKEN,
14
    },
15
    body: undefined,
16
  });
17
  if (!response.ok) {
18
    const text = await response.text();
19
    throw new Error(`${response.status} ${text}`);
20
  }
21
  return await response.text();
22
}
23