Skip to content

Function: domEnv()

Documentation / @wtf/platform-browser / env / domEnv

function domEnv(__namedParameters): Env;

Defined in: packages/platform-browser/src/env.ts:92

The environment the page carries, read once, a copy, frozen: of the block of JSON, <script type="application/json" id="env">{"API_URL": "https://example.com"}</script>, and of the meta tags, <meta name="env:API_URL" content="https://example.com">, a tag’s value over the block’s, as from has it by default. A page of neither gives an empty one.

import { domEnv } from '@wtf/platform-browser/env'
const env = domEnv({ document, from: 'meta' })

A value of the block is a string, or null of no value. A block that is no <script type="application/json">, whose text is no object of JSON, or of a value of another kind, is a SystemError of InvalidData. What a page carries is the page’s: anyone who loads it reads it, so it never holds a secret.

Parameters

ParameterType
__namedParametersDomEnvOptions

Returns

Env