github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/top-level-functions/FETCH.md (about)

     1  ---
     2  name: FETCH
     3  parameters:
     4    - url
     5    - args
     6  ts_ignore: true
     7  # Make sure to update fetch.d.ts if changing the docs below!
     8  ---
     9  
    10  `FETCH` is a wrapper for the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This allows dynamically setting DNS records based on an external data source, e.g. the API of your cloud provider.
    11  
    12  Compared to `fetch` from Fetch API, `FETCH` will call [PANIC](PANIC.md) to terminate the execution of the script, and therefore DNSControl, if a network error occurs.
    13  
    14  Otherwise the syntax of `FETCH` is the same as `fetch`.
    15  
    16  `FETCH` is not enabled by default. Please read the warnings below.
    17  
    18  > WARNING:
    19  >
    20  > 1. Relying on external sources adds a point of failure. If the external source doesn't work, your script won't either. Please make sure you are aware of the consequences.
    21  > 2. Make sure DNSControl only uses verified configuration if you want to use `FETCH`. For example, an attacker can send Pull Requests to your config repo, and have your CI test malicious configurations and make arbitrary HTTP requests. Therefore, `FETCH` must be explicitly enabled with flag `--allow-fetch` on DNSControl invocation.
    22  
    23  {% code title="dnsconfig.js" %}
    24  ```javascript
    25  D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
    26    A("@", "1.2.3.4"),
    27  END);
    28  
    29  FETCH("https://example.com", {
    30    // All three options below are optional
    31    headers: {"X-Authentication": "barfoo"},
    32    method: "POST",
    33    body: "Hello World",
    34  }).then(function(r) {
    35    return r.text();
    36  }).then(function(t) {
    37    // Example of generating record based on response
    38    D_EXTEND("example.com", [
    39      TXT("@", t.slice(0, 100)),
    40    ]);
    41  });
    42  ```
    43  {% endcode %}