getDefaultTransport()
function getDefaultTransport(): Promise<DefaultTransport | undefined>;
The default dispatcher and its paired fetch, as a single value so the two
are always read consistently. Resolves to undefined outside Node (browser/
edge), where callers use the global fetch with no dispatcher.
Use this when supplying a customFetch that should still honour the proxy
environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) and decode
compressed responses the way the SDK does by default.
Both halves must be used together. dispatcher decompresses the response
body itself, so a fetch from a different undici build will try to decode
it a second time and the request fails mid-stream with terminated. A
fetch of undefined means the runtime's global fetch is the correct
partner for this dispatcher.
Returns
Promise<DefaultTransport | undefined>
Example
const transport = await getDefaultTransport()
const fetchImpl = transport?.fetch ?? fetch
const response = await fetchImpl(url, { ...options, dispatcher: transport?.dispatcher })