A wrapper over Obsidian’s requestUrl that fills the gaps plugins keep hand-rolling: an abort signal and a timeout, request bodies beyond string | ArrayBuffer (FormData, URLSearchParams, Blob, typed arrays and streams), an error that carries the status and the body, an up-front protocol check, a streamed response body, and a fetch-compatible adapter that third-party SDKs can take.
requestUrl itself cannot be cancelled: an abort or a timeout settles the returned promise at once, while the underlying request runs to completion and its result is dropped. The streamed variant really cancels on desktop, where it goes through node:http / node:https; that module is imported dynamically, so this one stays cross-platform-loadable. On mobile the streamed variant falls back to requestUrl and delivers the whole body as a single chunk.
| Function |
Description |
| createRequestUrlFetch |
Creates a fetch-compatible function built on requestUrl, for SDKs that take a custom fetch (OpenAI, LangChain, OAuth clients) and would otherwise hit CORS. Unlike fetch, it never rejects on an HTTP error status: it resolves with a Response carrying that status, exactly as fetch does. It rejects with a TypeError for a URL that is not http: or https:. |
| encodeRequestUrlRequest |
Encodes a request for a transport: validates the URL, combines the abort signal with the timeout, encodes the body and settles the content type. |
| requestUrlEx |
Requests a URL through requestUrl, with an abort signal, a timeout, richer bodies, a protocol check and a RequestUrlError for an HTTP error status. |
| requestUrlStream |
Requests a URL and returns its body as a stream. On desktop the request goes through node:http / node:https, so the body streams as it arrives, an abort really cancels the request, and redirects are followed. On mobile it falls back to requestUrl, and the whole body arrives as a single chunk. |