api.network
Interface: INetworkApi
Implementation tier: T2
Make outbound HTTP/HTTPS requests. Hosts must be declared in the manifest's allowedHosts list.
Permissions
network
Methods
fetch
fetch(url: string, init?: NetworkFetchInit): Promise<NetworkFetchResponse>
Mediated outbound HTTP/HTTPS request. The URL's host MUST appear in the
extension's network.allowedHosts manifest entry; otherwise the call
rejects with NetworkHostNotAllowedError even if network permission is
granted.
Private-network destinations (loopback, RFC1918, link-local) are blocked
by default. To target a private host, the extension must list a literal
IP or hostname in allowedHosts and the user must approve it explicitly
at install time (the consent dialog highlights private targets).
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Yes | |
init | NetworkFetchInit | No |
Returns: Promise<NetworkFetchResponse>
isHostAllowed
isHostAllowed(host: string): Promise<boolean>
True if the host is currently in the extension's allowlist.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
host | string | Yes |
Returns: Promise<boolean>