@zturnlibs/ztron-api


http

Interfaces

FetchOptions

Defined in: http.ts:33

Properties

body?

optional body?: HttpRequestBody

Defined in: http.ts:36

headers?

optional headers?: Record<string, string>

Defined in: http.ts:35

method?

optional method?: string

Defined in: http.ts:34

responseType?

optional responseType?: "text" | "json" | "binary"

Defined in: http.ts:40

"text" (default) | "json" | "binary". Streaming stays fetchStream().

timeoutMs?

optional timeoutMs?: number

Defined in: http.ts:38

Abort the request after N milliseconds.


HttpResponse

Defined in: http.ts:8

Properties

binary?

optional binary?: Uint8Array<ArrayBufferLike>

Defined in: http.ts:23

Present when responseType:"binary" (bytes).

body

body: string

Defined in: http.ts:12

headers

headers: Record<string, string>

Defined in: http.ts:11

json?

optional json?: unknown

Defined in: http.ts:21

Present when responseType:"json".

ok

ok: boolean

Defined in: http.ts:10

status

status: number

Defined in: http.ts:9


HttpStreamResponse

Defined in: http.ts:77

A streaming response: headers first, body chunks as they arrive.

Properties

body

body: ReadableStream<Uint8Array<ArrayBufferLike>>

Defined in: http.ts:82

The response body as a byte stream (resolves progressively).

headers

headers: Record<string, string>

Defined in: http.ts:80

ok

ok: boolean

Defined in: http.ts:79

status

status: number

Defined in: http.ts:78

Type Aliases

HttpRequestBody

HttpRequestBody = string | Uint8Array | ArrayBuffer | Record<string, unknown>

Defined in: http.ts:26

Variables

http

const http: object

Defined in: http.ts:163

Type Declaration

fetch

fetch: (url, options) => Promise<HttpResponse>

Performs a scoped HTTP request; throws if the URL is out of scope.

Parameters
url

string

options?

FetchOptions = {}

Returns

Promise<HttpResponse>

fetchStream

fetchStream: (url, options) => Promise<HttpStreamResponse>

Performs a scoped HTTP request whose body is delivered as a stream: the returned promise resolves as soon as status + headers are available, and body yields each network chunk (Uint8Array) as it arrives — the app never has to buffer the whole response. Errors mid-stream reject the body read.

Parameters
url

string

options?

FetchOptions = {}

Returns

Promise<HttpStreamResponse>

Functions

fetch()

fetch(url, options?): Promise<HttpResponse>

Defined in: http.ts:67

Performs a scoped HTTP request; throws if the URL is out of scope.

Parameters

url

string

options?

FetchOptions = {}

Returns

Promise<HttpResponse>


fetchStream()

fetchStream(url, options?): Promise<HttpStreamResponse>

Defined in: http.ts:101

Performs a scoped HTTP request whose body is delivered as a stream: the returned promise resolves as soon as status + headers are available, and body yields each network chunk (Uint8Array) as it arrives — the app never has to buffer the whole response. Errors mid-stream reject the body read.

Parameters

url

string

options?

FetchOptions = {}

Returns

Promise<HttpStreamResponse>