0
get resource value
One script reply has been approved by the moderators Verified
Created by admin 479 days ago Viewed 9265 times
0
Submitted by admin Typescript (fetch-only)
Verified 479 days ago
1
/**
2
 * get resource value
3
 *
4
 */
5
export async function main(workspace: string, path: string) {
6
  const url = new URL(
7
    `${BASE_URL}/api/w/${workspace}/resources/get_value/${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.json();
22
}
23