0

get resource value

by admin
Published Aug 13, 2023
Script windmill
  • Submitted by admin Typescript (fetch-only)
    Created 561 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