0
get current usage outside of premium workspaces
One script reply has been approved by the moderators Verified
Created by admin 263 days ago Viewed 5432 times
0
Submitted by admin Typescript (fetch-only)
Verified 263 days ago
1
/**
2
 * get current usage outside of premium workspaces
3
 *
4
 */
5
export async function main() {
6
  const url = new URL(`${BASE_URL}/api/users/usage`);
7

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