0
Get Account Custom Nameserver Related Zone Metadata
One script reply has been approved by the moderators Verified

Get metadata for account-level custom nameservers on a zone.

Created by hugo697 297 days ago Viewed 8978 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 297 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Get Account Custom Nameserver Related Zone Metadata
8
 * Get metadata for account-level custom nameservers on a zone.
9

10
 */
11
export async function main(auth: Cloudflare, zone_identifier: string) {
12
  const url = new URL(
13
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_ns`
14
  );
15

16
  const response = await fetch(url, {
17
    method: "GET",
18
    headers: {
19
      "X-AUTH-EMAIL": auth.email,
20
      "X-AUTH-KEY": auth.key,
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31