Appearance
Function: createAgent()
ts
function createAgent(options?: CreateAgentOptions): Promise<HttpProxyAgent<string> | HttpsProxyAgent<string> | undefined>;Defined in: packages/sdk/src/proxy/index.ts:161
Create an HTTP or HTTPS proxy agent from the system proxy settings (Windows registry) or the standard proxy env vars. Returns undefined when no proxy is configured. Pass ca to trust additional roots for the upstream TLS.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | CreateAgentOptions | Optional {ca} certificates for the upstream TLS. |
Returns
Promise<HttpProxyAgent<string> | HttpsProxyAgent<string> | undefined>
The proxy agent, or undefined if no proxy applies.
Example
ts
const agent = await createAgent();
if (agent) {
fetch('https://api.example.com/invoices', { agent });
}