0

List Workers

by
Published today

List the Worker scripts deployed in the account.

Script cloudflare Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 hours ago
1
//native
2

3
/**
4
 * List Workers
5
 * List the Worker scripts deployed in the account.
6
 */
7
export async function main(auth: RT.Cloudflare) {
8
  const response = await fetch(
9
    `https://api.cloudflare.com/client/v4/accounts/${auth.account_id}/workers/scripts`,
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/json",
14
      },
15
    }
16
  )
17

18
  if (!response.ok) {
19
    throw new Error(`${response.status} ${await response.text()}`)
20
  }
21

22
  return await response.json()
23
}
24